// Project FamilyTree // Class Person // The instance variables are the name of the // person and a Vector object containing the // person's children. import java.util.*; public class Person { final static int MAXCHILDREN = 100; private String name; private int childCount; private Person[ ] children; public Person(String theName) { name = theName; children = new Person[MAXCHILDREN]; childCount = 0; } public String getName( ) { return name; } public void addChild(Person thePerson) { if (childCount < MAXCHILDREN - 1) children[childCount++] = thePerson; else System.out.printf("Maxed out at %d children\r\n", MAXCHILDREN); } public Person getChild(int index) { if (0 <= index && index <= childCount - 1) return children[index]; else { System.out.println("Illegal index in getChild."); return null; } } public int getNumberOfChildren() { return childCount; } public String toString( ) { String output = name + "\r\n"; for(int i = 0; i <= childCount - 1; i++) output += children[i].toString( ); return output; } }