All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class java.lancs.Person

java.lang.Object
   |
   +----java.lancs.Person

public class Person
extends Object
Represents simple facts about a person


Variable Index

 o FEMALE
Constant - female gender
 o MALE
Constant - male gender
 o UNKNOWN
Constant - unknown gender

Constructor Index

 o Person()
Creates an instance of the Person class with default values (forename = "NONE", surname = "NONE", age = 0, gender = UNKNOWN)
 o Person(String, String, int, int)
Creates an instance of the Person class with specified attribute values

Method Index

 o copy()
return a copy of the person
 o formalTitle()
return the formal title of the person
 o getAge()
returns the age attribute of the person
 o getForename()
returns the forename attribute of the person
 o getGender()
returns the gender attribute of the person
 o getGenderString()
returns the gender attribute of the person as a String
 o getSurname()
returns the surname attribute of the person
 o getUpperAgeLimit()
returns the upper limit for a valid age
 o increaseAge(int)
increase the age of the person by the specified amount
 o setAge(int)
set the age attribute of the person
 o setForename(String)
set the forename attribute of the person
 o setFullName(String, String)
set the full name of the person in one operation
 o setGender(int)
set the gender atribute of the person
 o setSurname(String)
set the surname attribute of the person
 o toString()
return a string representing the person

Variables

 o UNKNOWN
 public static final int UNKNOWN
Constant - unknown gender

 o MALE
 public static final int MALE
Constant - male gender

 o FEMALE
 public static final int FEMALE
Constant - female gender

Constructors

 o Person
 public Person()
Creates an instance of the Person class with default values (forename = "NONE", surname = "NONE", age = 0, gender = UNKNOWN)

 o Person
 public Person(String f,
               String s,
               int a,
               int g)
Creates an instance of the Person class with specified attribute values

Parameters:
f - forename of the person
s - surname of the person
a - age of the person
g - gender of the person

Methods

 o getUpperAgeLimit
 public static int getUpperAgeLimit()
returns the upper limit for a valid age

Returns:
the upper limit for a valid age
 o getForename
 public String getForename()
returns the forename attribute of the person

Returns:
the forename attribute of the person
 o getSurname
 public String getSurname()
returns the surname attribute of the person

Returns:
the surname attribute of the person
 o getAge
 public int getAge()
returns the age attribute of the person

Returns:
the age attribute of the person
 o getGender
 public int getGender()
returns the gender attribute of the person

Returns:
the gender attribute of the person
 o getGenderString
 public String getGenderString()
returns the gender attribute of the person as a String

Returns:
the gender attribute of the person as a String
 o setForename
 public void setForename(String f)
set the forename attribute of the person

Parameters:
f - the forename of the person
 o setSurname
 public void setSurname(String s)
set the surname attribute of the person

Parameters:
s - the surname of the person
 o setAge
 public void setAge(int a)
set the age attribute of the person

Parameters:
a - the age of the person
 o setGender
 public void setGender(int g)
set the gender atribute of the person

Parameters:
g - the gender of the person
 o increaseAge
 public void increaseAge(int n)
increase the age of the person by the specified amount

Parameters:
n - the number of years by which the age attribute should be increased
 o setFullName
 public void setFullName(String f,
                         String s)
set the full name of the person in one operation

Parameters:
f - the forename of the person
s - the surname of the person
 o formalTitle
 public String formalTitle()
return the formal title of the person

Returns:
the formal name of the person ('Mr' or 'Ms', initial, surname)
 o toString
 public String toString()
return a string representing the person

Returns:
details of the person ('forename surname (age: gender)')
Overrides:
toString in class Object
 o copy
 public Person copy()
return a copy of the person

Returns:
a copy of the Person instance

All Packages  Class Hierarchy  This Package  Previous  Next  Index