import java.util.*; import java.io.*; public class FullTimeEmployeeDriver { protected FullTimeEmployee e1, e2; protected BufferedReader keyboardReader, fileReader; protected PrintWriter fileWriter; public PrintWriter openFiles() { final String IN_FILE_PROMPT = "\nPlease enter the name of the input file: "; final String OUT_FILE_PROMPT = "\nPlease enter the name of the output file: "; BufferedReader keyboardReader; boolean filesOK = false; while (!filesOK) { try { keyboardReader = new BufferedReader (new InputStreamReader (System.in)); System.out.print (IN_FILE_PROMPT); fileReader = new BufferedReader (new FileReader (keyboardReader.readLine())); System.out.print (OUT_FILE_PROMPT); fileWriter = new PrintWriter (new BufferedWriter (new FileWriter (keyboardReader.readLine()))); filesOK = true; } // try catch (IOException e) { System.out.println (e); } // catch } // while files not OK return fileWriter; } // method openFiles public void testAllMethods() { String line; while (true) { try { line = fileReader.readLine(); if (line == null) break; fileWriter.println (line); testMethod (line); } // try catch (IOException e) { fileWriter.println (e); } // catch catch (NoSuchElementException e) { fileWriter.println (e); } // catch catch (NumberFormatException e) { fileWriter.println (e); } // catch } // while } // method testAllMethods public void testMethod (String line) { FullTimeEmployee callingObject, argument; StringTokenizer st = new StringTokenizer (line); String temp = st.nextToken(); if (temp.equals ("e1")) callingObject = e1; else callingObject = e2; String method = st.nextToken(); if (method.equals ("FullTimeEmployee")) { if (st.countTokens() == 0) callingObject = new FullTimeEmployee(); else callingObject = new FullTimeEmployee ( st.nextToken() + " " + st.nextToken()); if (temp.equals ("e1")) e1 = callingObject; else e2 = callingObject; } // if constructor else if (method.equals ("toString")) fileWriter.println (callingObject.toString()); else if (method.equals ("makesMoreThan")) { if (st.nextToken().equals ("e1")) argument = e1; else argument = e2; fileWriter.println (callingObject.makesMoreThan (argument)); } // testing makesMoreThan } // method testMethod } // class FullTimeEmployeeDriver