From: <b_...@us...> - 2003-07-26 11:45:10
|
Update of /cvsroot/ordweb/uop/pos407/bryanm/week4 In directory sc8-pr-cvs1:/tmp/cvs-serv4627 Modified Files: ThrowEmployee.java Log Message: Added comments. Index: ThrowEmployee.java =================================================================== RCS file: /cvsroot/ordweb/uop/pos407/bryanm/week4/ThrowEmployee.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ThrowEmployee.java 24 Jul 2003 05:25:32 -0000 1.2 --- ThrowEmployee.java 25 Jul 2003 17:20:49 -0000 1.3 *************** *** 1,19 **** /** * Created By: Bryan Meier ! * Date: 7/23/03 ! * Class: POS407 ! * Instructor: Colin Goble */ public class ThrowEmployee { public static void main(String[] args) throws Exception { ! Employee[] emp = new Employee[3]; ! for (int i = 0; i < 3; i++) { try { emp[i] = new Employee(i + 1, i * 30); } ! catch (EmployeeException error) { System.out.println("Employee error: " + error.getMessage()); } --- 1,25 ---- /** * Created By: Bryan Meier ! * Date: ! * Class: ! * Instructor: */ + /** + * Throw Employee is the driver to this program. + */ public class ThrowEmployee { public static void main(String[] args) throws Exception { ! Employee[] emp = new Employee[3]; //Create array of 3 Employees. ! //Create employees and add them to the Array. ! //Employee ID is the Array number + 1. ! //Employee wage is the Array Number * #30. ! for (int i = 0; i < emp.length; i++) { try { emp[i] = new Employee(i + 1, i * 30); } ! catch (EmployeeException error) { //Catch errors based on Employee's Exceptions. System.out.println("Employee error: " + error.getMessage()); } *************** *** 22,25 **** --- 28,34 ---- } + /** + * Exception Class. + */ class EmployeeException extends Exception { EmployeeException(String s) { *************** *** 28,39 **** --- 37,57 ---- } + /** + * Employee class is used to create Employee objects. + */ class Employee { int idNum; double hourlyWage; + /** + * @param id + * @param wage + * @throws EmployeeException + */ Employee (int id, double wage) throws EmployeeException { idNum = id; hourlyWage = wage; + //If Employee's hourlyWage is less then $6 then throw EmployeeException. if (hourlyWage < 6.00) { String s = "Employee " + idNum + " makes $" + hourlyWage + 0 + " which is under $6.00."; *************** *** 41,44 **** --- 59,63 ---- } + //If Employee's hourlyWage is greater then $50 then throw EmployeeException. if (hourlyWage > 50.00) { String s = "Employee " + idNum + " makes $" + hourlyWage + 0 + " which is more $50.00."; |