public class School { private String name; private int zip; private int enrol; /** Given a line of text from the input file, we need to parse out * what we need: the school's name, ZIP code and enrolment. * According to the record layout, they are given at certain points * on the line, as given below in the calls to substring(). * It turns out that for some schools, ZIP code or enrolment data are * unknown, and in the data file this is signified by an "N". */ public School(String line) { name = line.substring(106, 156); String zipString = line.substring(299, 304); if (zipString.indexOf('N') >= 0 || zipString.indexOf('M') >= 0) zip = 0; else zip = Integer.parseInt(line.substring(299, 304)); String enrolString = line.substring(1322, 1326); if (enrolString.indexOf('N') >= 0 || enrolString.indexOf('M') >= 0) enrol = 0; else enrol = Integer.parseInt(line.substring(1322, 1326)); } public int getZip() { return zip; } public int getEnrol() { return enrol; } public String toString() { return name + " " + zip + " " + enrol; } }