Employees: Create an Employee class that has two attributes of an employee: the employee's name and rate of pay. In addition to the public methods getName() and getRate(), the class should define an abstract method computePay( int hours ) that returns double.
In addition, create two subclasses of the Employee class: HourlyEmployee and SalariedEmployee. Implement the computePay method in each subclass according to the following specifications:
The first 40 hours that an hourly employee works are "regular" hours, and any hours beyond the first 40 hours are "overtime" hours.
An hourly employee is paid their standard rate of pay for all regular hours worked, but is paid time-and-a-half (i.e., 1.5 times the standard rate) for all overtime hours worked.
A salaried employee is paid a fixed amount for each pay period, equal to that employee's standard rate of pay times the number of regular hours in a week (i.e., 40).
The following test class illustrates how the various employee classes can be used. Note that the printPay method is polymorphic: the type of the first parameter is Employee, but when it calls the computePay method on the employee object, it is actually invoking the computePay method of either an HourlyEmployee or a SalariedEmployee, depending on which type of object was passed by the calling method (main).
Your solution should display the following characteristics:
Correctness - The program should conform to the specifications for which it was written. It should include correct handling of any error conditions that might occur.
Design and Efficiency - Each class should be constructed from small, coherent methods. The control constructs and data structures used should be those appropriate to the problem at hand. The program should not perform unnecessary steps, use extraneous variables, nor implement the algorithm in a contorted or inefficient way.
Style and Documentation - The program should conform to generally accepted principles of style, such as a consistent pattern of indentation, use of meaningful identifiers, generous use of space, etc., as specified in the Programming Style Guide (see Appendix A, pp. 863ff.) Internal documentation should include class and method headers, and in-line comments to clarify the code where appropriate.
This assignment will account for 8% of your final grade in the course.
Submit your source code (i.e., your .java files) electronically using the following submission form. In order to work correctly with the test program, your Java files should have the names shown in the form.
You may submit one or more of your files multiple times; only the last version submitted will be graded. Late submissions will be accepted, but will be subject to a penalty of 1% per hour or portion thereof.
Your assignment submissions are password-protected. These passwords apply only to form data submitted via the Web server. They are separate from (and typically different from) your network password.