Package edu.pdx.cs410J.family
Class Person
java.lang.Object
edu.pdx.cs410J.family.Person
- All Implemented Interfaces:
Serializable
This class represents a person in a family tree. Each person has a
required unique id. Additionally, a person may have a first,
middle, and last name, a date of birth, a date of death, and may be
involved in one or more marriages.
- Author:
- David Whitlock
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic Person.Genderstatic Person.Genderstatic final intA constant representing the id of an unknown person -
Constructor Summary
ConstructorsConstructorDescriptionPerson(int id) Creates a person of unknown gender.Person(int id, Person.Gender gender) Creates a newPersonwith a given id and gender. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddMarriage(Marriage marriage) Makes note of a marriage this person was involved in.booleanDetermines whether or not thisPersonis equal to anotherPerson.Returns this person's date of birth.Returns this person's date of death.Returns this person's father.intReturns the id of this person's father.Returns this person's first name.Returns this person's full (first, middle, and last) name.Returns this person's genderintgetId()Returns this person's id.Returns this person's last name.Returns the marriages that this person was involved in.Returns this person's middle name.Returns this person's mother.intReturns the id of this person's mother.(package private) voidpatchUp(FamilyTree tree) "Patches up" a person's mother and fatherPersonobjects.voidsetDateOfBirth(Date dob) Sets this person's date of birth.voidsetDateOfDeath(Date dod) Sets this person's date of death.voidSets this person's father.(package private) voidsetFatherId(int id) Sets the id of this person's father.voidsetFirstName(String firstName) Sets this person's first name.(package private) voidsetGender(Person.Gender gender) Sets this person's gender.voidsetLastName(String lastName) Sets this person's last name.voidsetMiddleName(String middleName) Sets this person's middle name.voidSets this person's mother.(package private) voidsetMotherId(int id) Sets the id of this person's mother.toString()Returns a brief description of this person.
-
Field Details
-
MALE
-
FEMALE
-
UNKNOWN
A constant representing the id of an unknown person- See Also:
-
-
Constructor Details
-
Person
Creates a newPersonwith a given id and gender. AnUNKNOWNperson cannot be created.- Throws:
FamilyTreeException-idis less than 1 orgenderis neitherMALEnorFEMALE
-
Person
Person(int id) Creates a person of unknown gender. Note that this method is package protected and is meant to be invoked by parsers, etc. in which we have to create a person before we know its gender.
-
-
Method Details
-
getId
Returns this person's id. -
setGender
Sets this person's gender. Note that this method is package protected.- Throws:
FamilyTreeException- Thegenderis neitherMALEnorFEMALE.- See Also:
-
getGender
Returns this person's gender -
setFirstName
Sets this person's first name. -
getFirstName
Returns this person's first name. -
setMiddleName
Sets this person's middle name. -
getMiddleName
Returns this person's middle name. -
setLastName
Sets this person's last name. -
getLastName
Returns this person's last name. -
getFullName
Returns this person's full (first, middle, and last) name. -
setFather
Sets this person's father.- Throws:
FamilyTreeException-fatheris notMALE
-
getFatherId
Returns the id of this person's father.- Returns:
UNKNOWN, if this person's father is not known
-
getFather
Returns this person's father. -
setFatherId
Sets the id of this person's father. This method is package protected because it is only intended to be access by parsers and other objects that would see a peron's id before the person is created. -
setMother
Sets this person's mother.- Throws:
FamilyTreeException-mother's gender is notFEMALE
-
getMotherId
Returns the id of this person's mother.- Returns:
UNKNOWN, if this person's father is not known
-
getMother
Returns this person's mother. -
setMotherId
Sets the id of this person's mother. This method is package protected because it is only intended to be accessed by parsers and other objects that would see a peron's id before the person is created. -
patchUp
"Patches up" a person's mother and fatherPersonobjects. This method is package protected because it is only intended to be accessed by parsers and other objects that would see a peron's id before the person is created.- Throws:
FamilyTreeException- Either the mother or father does not existin intreeor if the gender has not been set
-
setDateOfBirth
Sets this person's date of birth. -
getDateOfBirth
Returns this person's date of birth. -
setDateOfDeath
Sets this person's date of death.- Throws:
FamilyTreeException- If this person's data of birth is known anddodoccurs before it.
-
getDateOfDeath
Returns this person's date of death. -
addMarriage
Makes note of a marriage this person was involved in.- Throws:
FamilyTreeException- If this person is not one of the spouses in the marriage
-
getMarriages
Returns the marriages that this person was involved in. -
equals
Determines whether or not thisPersonis equal to anotherPerson. TwoPersons are considered equal if they have the same id. -
toString
Returns a brief description of this person.
-