edu.pdx.cs399J.family
Class FamilyTree

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

public class FamilyTree
extends Object
implements Serializable

This class represents a family tree. Essentially, it is a collection of people. Family trees are always rooted at the person with id 1.

Author:
David Whitlock
See Also:
Serialized Form

Constructor Summary
FamilyTree()
          Creates an empty family tree.
 
Method Summary
 void addPerson(Person person)
          Adds a person to this family tree.
 boolean containsPerson(int id)
          Returns whether or not this family tree contains a person with the given id.
 Collection<Person> getPeople()
          Returns a collection of Persons that are in this family tree.
 Person getPerson(int id)
          Returns a person in this family tree with a given id.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FamilyTree

public FamilyTree()
Creates an empty family tree.

Method Detail

getPeople

public Collection<Person> getPeople()
Returns a collection of Persons that are in this family tree.


containsPerson

public boolean containsPerson(int id)
Returns whether or not this family tree contains a person with the given id.


getPerson

public Person getPerson(int id)
Returns a person in this family tree with a given id. If no person with that id exists in this family tree, then null is returned.


addPerson

public void addPerson(Person person)
Adds a person to this family tree. If a person with the same id as the person being added already exists in this family tree, the old person is removed and replaced with the new.


toString

public String toString()
Overrides:
toString in class Object


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