import java.io.*; import java.util.*; /** Candidate main program * * @author Duncan Buell * * NOTE: The commented lines are the old ArrayList code, and the * lines immediately following is the code for using an array instead. * * written: 18 November 2007 */ public class Main extends Object { public static void main(String[] args) { String inputFileName = null; Scanner inDataFile = null; // CandidateList theList = new CandidateList(); CandidateArray theArray = new CandidateArray(25); inputFileName = "theDataFile.dat"; inDataFile = DAB.ScannerOpen(inputFileName); System.out.println("Input file '" + inputFileName + "' opened, continue"); /******************************************************************************/ /** Read in the list of candidates **/ System.out.println("Read in the data"); // theList.getTheList(inDataFile); theArray.getTheArray(inDataFile); System.out.println("The data has been read"); /******************************************************************************/ /** Use the data in the array list **/ System.out.printf("%nThe entire list of candidates is%n"); // theList.printTheList(); theArray.printTheArray(); System.out.printf("%nThe list of Democratic candidates is%n"); // theList.printByParty("DEM"); theArray.printByParty("DEM"); System.out.printf("%nThe list of Republican candidates is%n"); // theList.printByParty("REP"); theArray.printByParty("REP"); System.out.printf("%nThe list of New Yorkers who are candidates is%n"); // theList.printByState("NY"); theArray.printByState("NY"); System.out.printf("%nThe list of Democratic candidates is%n"); // theList.printWithMatch(Fields.PARTY, "DEM"); theArray.printWithMatch(Fields.PARTY, "DEM"); } // public static void main(String[] args) } // public class Main extends Object