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
-
Field Summary
Modifier and TypeFieldDescriptionstatic Person.Gender
static Person.Gender
static final int
A constant representing the id of an unknown person -
Constructor Summary
ConstructorDescriptionPerson
(int id) Creates a person of unknown gender.Person
(int id, Person.Gender gender) Creates a newPerson
with a given id and gender. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addMarriage
(Marriage marriage) Makes note of a marriage this person was involved in.boolean
Determines whether or not thisPerson
is equal to anotherPerson
.Returns this person's date of birth.Returns this person's date of death.Returns this person's father.int
Returns 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 genderint
getId()
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.int
Returns the id of this person's mother.(package private) void
patchUp
(FamilyTree tree) "Patches up" a person's mother and fatherPerson
objects.void
setDateOfBirth
(Date dob) Sets this person's date of birth.void
setDateOfDeath
(Date dod) Sets this person's date of death.void
Sets this person's father.(package private) void
setFatherId
(int id) Sets the id of this person's father.void
setFirstName
(String firstName) Sets this person's first name.(package private) void
setGender
(Person.Gender gender) Sets this person's gender.void
setLastName
(String lastName) Sets this person's last name.void
setMiddleName
(String middleName) Sets this person's middle name.void
Sets this person's mother.(package private) void
setMotherId
(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 newPerson
with a given id and gender. AnUNKNOWN
person cannot be created.- Throws:
FamilyTreeException
-id
is less than 1 orgender
is neitherMALE
norFEMALE
-
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
- Thegender
is neitherMALE
norFEMALE
.- 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
-father
is 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 fatherPerson
objects. 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 intree
or 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 anddod
occurs 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 thisPerson
is equal to anotherPerson
. TwoPerson
s are considered equal if they have the same id. -
toString
Returns a brief description of this person.
-