import java.io.*; public class Person { // max # of people in database. private final static int maxN = 100; // folks[0..n] are people in database. private static Person[] folks = new Person[maxN]; private static int n = 0; private String name; // person's name. private boolean male; // person's maleness. // Construct Person named s of maleness m. public Person(String s, boolean m) { name = s; male = m; if ( n >= maxN ) System.out.println("over limit"); else { folks[n] = this; n++; } } // # of people in database. public static int numberOfPeople() { return n; } // i-th Person in database. public static Person intToPerson(int i) { if (i < 0 || i >= n) return null; else return folks[i]; } // string representation of a Person. public String toString() { String result; result = "name:"+ name; if (male) result = result + " sex:male"; else result = result + " sex:female"; return result; } }