import java.io.*; // CS100 Fall 2000 Assignment 3. public class Program3 { // Display every person in the database. static void showPeople() { int n = Person.numberOfPeople(); for (int j=0; j < n; j++){ Person p = Person.intToPerson(j); System.out.println(p); } } // Return the person with name s in the database. public static Person stringToPerson(String s) { int n = Person.numberOfPeople(); int j=0; // loop until the person is found while (j < n && !s.equals(Person.intToPerson(j).name())) j++; // return the person if j is valid if (j "); String s = in.readString(); // begin the loop that processes each command while ( !s.equals("q")){ /* process command s. */ if ( s.equals("b")) new Person(in.readString(), true); else if ( s.equals("g")) new Person(in.readString(), false); else if ( s.equals("?")) System.out.println(stringToPerson(in.readString())); else if ( s.equals("p")) showPeople(); else if ( s.equals("m")){ Person.marry( stringToPerson(in.readString()), stringToPerson(in.readString())); } else if ( s.equals("s") || s.equals("d")){ Person mom; Person dad; Person p = stringToPerson(in.readString()); if ( p.male() ){ dad = p; mom = p.other(); } else { mom = p; dad = p.other(); } Person.child(mom, dad, in.readString(), s.equals("s")); } // Get next query System.out.print("> "); System.out.flush(); s = in.readString(); } } }