Question: In this lab you will derive an abstract class called Employee from the Person class and derive two concrete classes from Employee called Salary Employee
In this lab you will derive an abstract class called Employee from the Person class and derive two concrete classes from Employee called Salary Employee and HourlyEmployee. The abstract Employee class will declare an abstract method called getEarnings() (This is similar to the earnings() method used in chapter 10 of your text.). The subclasses of Employee will provide different implementations of these methods.
You will then create a new program called PayrollReporter that manipulates an array that contains both SalaryEmployee and HourlyEmployee objects.
Step 1
In a new folder, create a modified version Employee class that derives from Person. The new version is abstract and defines an abstract method called getEarnings. Then derive the two new classes SalaryEmployee and HourlyEmployee. 


Step 2
Now create the PayrollReporter program. This program will allow the user to perform operations on an array that contains both SalaryEmployee and HourlyEmployee objects. It will do this by leveraging the is-a relationship these classes have with Employee and the polymorphic invocation of the getEarnings() method.
1. It will use an array of Employee objects called employees, declared like this:
static Employee[] employees;
2. In the main method populate the array with the following data. Notice that we are putting SalaryEmployees and HourlyEmployees into the same array of type Employee. (You can copy and paste this data)
employees = new Employee[10]; employees[0] = new SalaryEmployee("John", "Smith", 'T', new Date(6,24,80), 100101, 1, 12, 2894.54f);
employees[1] = new SalaryEmployee("Sue", "Jones", 'A', new Date(4,13,84), 100102, 1, 15, 3110.0f);
employees[2] = new HourlyEmployee("Marg", "Williams", 'C', new Date(1,28,70), '100103, 3, 15, 25.0f,81f);
employees[3] = new SalaryEmployee("Beth", "Davies", 'D', new Date(2,3,76), 200101, 3, 15, 2843.5f);
employees[4] = new SalaryEmployee("Jake", "Stewart", 'A', new Date(9,18,68), 100201, 1, 0, 2999.0f);
employees[5] = new HourlyEmployee("Alice", "McWilliams", 'F', new Date(10,9,80), 300203, 1, 0, 27.0f, 88f); employees[6] = new HourlyEmployee("Mike", "Klauss", 'M', new Date(12,12,76), 300213, 2, 0, 30.0f, 80f); employees[7] = new HourlyEmployee("Samuelle", "Chau", 'D', new Date(8,23,86), 400213, 2, 12, 22.0f, 85f);
employees[8] = new HourlyEmployee("Mitch", "Flynn", 'A', new Date(7,28,78), 990223, 3, 15, 100.0f, 80f);
employees[9] = new SalaryEmployee("Andrea", "Bouchard", 'S', new Date(3,20,85), 400023, 3, 12, 3900.0f); - There are 3 department codes in this example: 1,2 and 3 - There are 3 project codes in this example: 0, 12, 15
3. A menu in main will present the user with the following options
1. Display all earnings for employees 2. Display all earnings for a project number 3. Display all earnings for a department number 4. Display wage costs for all projects 5. Display wage costs for all departments 6. Display overtimes expenses 7. Exit
4. Display all earnings for employees will list all employees in the following format:
1. employeeNo : lastName, fisrtName middleInit. earnings
Follow the list with a total earnings row.
5. Display all earnings for a project number prompts the user for a project number and then displays a list with the same format as in 4 above, but only for employees associated with the selected project. Precede the list with a header, e.g. Project #1
6. Display all earnings for a department number performs the same operation as 5 above, but does it for a specific department.
7. Display wage costs for all projects displays a list of each project and the total wages spent on the project in the following format:
Project # Total Wages
8. Display wage costs for all departments displays a list of each department and the total wages spent on the project in the following format:
Department # Total Wages
9. Display overtime expenses displays a list of each employee who earned overtime, the number of overtime hours they worked and the amount of overtime pay they earned in the following format:
1. employeeNo : lastName, fisrtName middleInit. OT Hours : OT earnings
*Person and Date remain unchanged *Notice the italicized class name and method. These will be declared using the keyword abstract. Employee employeeNo: int departmentNo: int projectNo: int II O indicates unassigned + Employee(firstName : String , lastName : String, middlelnit : char, birthDate: Date, employeeNo: int, departmentNo: int, projectNo: int) + Employeel) + setEmployeeNoL employee No: int) + getEmployee Nol): int + setDepartmentNodepartmentNo: int) + getDepartmentNod) : int + setProjectNo( projectNo: int) + getProjectNo(): int + toString(): String + getEarnings!) : float SalaryEmployee monthly Salary: float + SalaryEmployee(firstName : String , lastName : String, middlelnit : char, birthDate : Date, employeeNo: int, departmentNo:int, project No : int, monthly Salary: float) + SalaryEmployeel) + setMonthly Salary(_monthly Salary: float) + getMonthly Salary(): float + getEarnings(): float //Returns earnings for a 2 week period HourlyEmployee hourlyRate : float hours Worked : float + HourlyEmployee(firstName : String , lastName : String, middlelnit : char, birth Date: Date, employeeNo: int, departmentNo: int, project No : int, hourlyRate float hours Worked : float) + HourlyEmplexeel) + setHourlyRate hourly Rate : float) + getHourlyRate(): float + setHoursWorked hoursWorked : float) + getHoursWorked): float + getEarnings!): float //Calculated over 2 weeks, time-and-a-half for hours over 80 *Person and Date remain unchanged *Notice the italicized class name and method. These will be declared using the keyword abstract. Employee employeeNo: int departmentNo: int projectNo: int II O indicates unassigned + Employee(firstName : String , lastName : String, middlelnit : char, birthDate: Date, employeeNo: int, departmentNo: int, projectNo: int) + Employeel) + setEmployeeNoL employee No: int) + getEmployee Nol): int + setDepartmentNodepartmentNo: int) + getDepartmentNod) : int + setProjectNo( projectNo: int) + getProjectNo(): int + toString(): String + getEarnings!) : float SalaryEmployee monthly Salary: float + SalaryEmployee(firstName : String , lastName : String, middlelnit : char, birthDate : Date, employeeNo: int, departmentNo:int, project No : int, monthly Salary: float) + SalaryEmployeel) + setMonthly Salary(_monthly Salary: float) + getMonthly Salary(): float + getEarnings(): float //Returns earnings for a 2 week period HourlyEmployee hourlyRate : float hours Worked : float + HourlyEmployee(firstName : String , lastName : String, middlelnit : char, birth Date: Date, employeeNo: int, departmentNo: int, project No : int, hourlyRate float hours Worked : float) + HourlyEmplexeel) + setHourlyRate hourly Rate : float) + getHourlyRate(): float + setHoursWorked hoursWorked : float) + getHoursWorked): float + getEarnings!): float //Calculated over 2 weeks, time-and-a-half for hours over 80
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
