Class Person

java.lang.Object
edu.pdx.cs410J.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:
  • Field Details

  • Constructor Details

    • 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
    • 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

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

      void setGender(Person.Gender gender)
      Sets this person's gender. Note that this method is package protected.
      Throws:
      FamilyTreeException - The gender is neither MALE nor FEMALE.
      See Also:
    • 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

      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.
    • setFatherId

      void setFatherId(int id)
      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.
      See Also:
    • 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.
    • setMotherId

      void setMotherId(int id)
      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.
      See Also:
    • patchUp

      void patchUp(FamilyTree tree)
      "Patches up" a person's mother and father Person 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 in tree or if the gender has not been set
    • 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

      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