edu.pdx.cs399J.family
Class Person

java.lang.Object
  extended by edu.pdx.cs399J.family.Person
All Implemented Interfaces:
Serializable

public class Person
extends Object
implements 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:
Serialized Form

Nested Class Summary
static class Person.Gender
           
 
Field Summary
static Person.Gender FEMALE
           
static Person.Gender MALE
           
static int UNKNOWN
          A constant representing the id of an unknown person
 
Constructor Summary
Person(int id, Person.Gender gender)
          Creates a new Person with a given id and gender.
 
Method Summary
 void addMarriage(Marriage marriage)
          Makes note of a marriage this person was involved in.
 boolean equals(Object o)
          Determines whether or not this Person is equal to another Person.
 Date getDateOfBirth()
          Returns this person's date of birth.
 Date getDateOfDeath()
          Returns this person's date of death.
 Person getFather()
          Returns this person's father.
 int getFatherId()
          Returns the id of this person's father.
 String getFirstName()
          Returns this person's first name.
 String getFullName()
          Returns this person's full (first, middle, and last) name.
 Person.Gender getGender()
          Returns this person's gender
 int getId()
          Returns this person's id.
 String getLastName()
          Returns this person's last name.
 Collection<Marriage> getMarriages()
          Returns the marriages that this person was involved in.
 String getMiddleName()
          Returns this person's middle name.
 Person getMother()
          Returns this person's mother.
 int getMotherId()
          Returns the id of this person's mother.
 void setDateOfBirth(Date dob)
          Sets this person's date of birth.
 void setDateOfDeath(Date dod)
          Sets this person's date of death.
 void setFather(Person father)
          Sets this person's father.
 void setFirstName(String firstName)
          Sets this person's first name.
 void setLastName(String lastName)
          Sets this person's last name.
 void setMiddleName(String middleName)
          Sets this person's middle name.
 void setMother(Person mother)
          Sets this person's mother.
 String toString()
          Returns a brief description of this person.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MALE

public static Person.Gender MALE

FEMALE

public static Person.Gender FEMALE

UNKNOWN

public static final int UNKNOWN
A constant representing the id of an unknown person

See Also:
Constant Field Values
Constructor Detail

Person

public Person(int id,
              Person.Gender gender)
Creates a new Person with a given id and gender. An UNKNOWN person cannot be created.

Throws:
FamilyTreeException - id is less than 1 or gender is neither MALE nor FEMALE
Method Detail

getId

public int getId()
Returns this person's id.


getGender

public Person.Gender getGender()
Returns this person's gender


setFirstName

public void setFirstName(String firstName)
Sets this person's first name.


getFirstName

public String getFirstName()
Returns this person's first name.


setMiddleName

public void setMiddleName(String middleName)
Sets this person's middle name.


getMiddleName

public String getMiddleName()
Returns this person's middle name.


setLastName

public void setLastName(String lastName)
Sets this person's last name.


getLastName

public String getLastName()
Returns this person's last name.


getFullName

public String getFullName()
Returns this person's full (first, middle, and last) name.


setFather

public void setFather(Person father)
Sets this person's father.

Throws:
FamilyTreeException - father is not MALE

getFatherId

public int getFatherId()
Returns the id of this person's father.

Returns:
UNKNOWN, if this person's father is not known

getFather

public Person getFather()
Returns this person's father.


setMother

public void setMother(Person mother)
Sets this person's mother.

Throws:
FamilyTreeException - mother's gender is not FEMALE

getMotherId

public int getMotherId()
Returns the id of this person's mother.

Returns:
UNKNOWN, if this person's father is not known

getMother

public Person getMother()
Returns this person's mother.


setDateOfBirth

public void setDateOfBirth(Date dob)
Sets this person's date of birth.


getDateOfBirth

public Date getDateOfBirth()
Returns this person's date of birth.


setDateOfDeath

public void setDateOfDeath(Date dod)
Sets this person's date of death.

Throws:
FamilyTreeException - If this person's data of birth is known and dod occurs before it.

getDateOfDeath

public Date getDateOfDeath()
Returns this person's date of death.


addMarriage

public void addMarriage(Marriage marriage)
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

public Collection<Marriage> getMarriages()
Returns the marriages that this person was involved in.


equals

public boolean equals(Object o)
Determines whether or not this Person is equal to another Person. Two Persons are considered equal if they have the same id.

Overrides:
equals in class Object

toString

public String toString()
Returns a brief description of this person.

Overrides:
toString in class Object


Copyright © 2000-2009 Portland State University. All Rights Reserved.