import java.io.*; public class Company { private FullTimeEmployee bestPaid; private boolean atLeastOneEmployee; /** * Initializes this Company object. * */ public Company() { bestPaid = new FullTimeEmployee(); atLeastOneEmployee = false; } // default constructor /** * Determines the best-paid full-time employee in this Company object. * */ public void findBestPaid () throws IOException // see Section 2.2 { final String SENTINEL = "***"; final String INPUT_PROMPT = "\nPlease enter a name (with no blanks) " + "and gross pay, followed by the Enter key. The sentinel is " + SENTINEL + " "; FullTimeEmployee employee; String line; BufferedReader reader = new BufferedReader (new InputStreamReader (System.in)); while (true) { System.out.print (INPUT_PROMPT); line = reader.readLine(); if (line.equals (SENTINEL)) break; employee = new FullTimeEmployee (line); atLeastOneEmployee = true; if (employee.makesMoreThan (bestPaid)) bestPaid = employee; }//while } // method findBestPaid /** * Prints out the best-paid full-time employee in the input, or an error * message if the only line of input is the sentinel. * */ public void printBestPaid() { final String BEST_PAID_MESSAGE = "\n\n\nThe best paid employee (and gross pay) is "; final String NO_INPUT_MESSAGE = "\n\n\nERROR: there were no employees in the input."; if (atLeastOneEmployee) System.out.println (BEST_PAID_MESSAGE + bestPaid); else System.out.println (NO_INPUT_MESSAGE); } // method printBestPaid } // class Company