Question: Concepts Inheritance Polymorphism Overview This homework introduces polymorphism and provides additional practice translating UML diagrams into code. Description In this assignment, you will implement the


Concepts Inheritance Polymorphism Overview This homework introduces polymorphism and provides additional practice translating UML diagrams into code. Description In this assignment, you will implement the inheritance hierarchy provided below. Notice that the Employee class has annualPay and monthlyPay methods. The annualPay method is also present in the Manager, Staff, FullTime and Part Time classes, while the monthly Pay is present in the SalariedEmployee and HourlyEmployee classes. This will give us our first look at polymorphic behavior with something other than to String. Employee name: String hireYear: int monthlyPay() annual Pay() SalariedEmployee annualSalary:int monthlyPay() HourlyEmployee hoursPerWeek:int hourlyllage:double monthlyPay() Manager annualPay() Staff annual Pay() Full Time annual Pay() Part Time annual Pay ( ) Employee Class Hierarchy Implement the seven classes shown above. For the purposes of this homework. DO NOT add a toString method to any of your classes. The pay calculations should be implemented as follows: Monthly pay: Employee: simply return zero Salaried Employee: annualSalary / 12 Hourly Employee: HoursPerWeek X 4 X hourly Wage Annual pay: Employee: simply return zero Manager: annual salary + 10% bonus Staff: annual salary + 2% bonus per year of service up to 5 years Full Time: 50 weeks of wages + 2 weeks wages as bonus Part Time: 50 weeks of wages (no bonus) Execution The execution class, named EmployeePay, provided here reads this data file (EmployeeData.txt) containing employee information, instantiates the appropriate objects and adds them to an ArrayList that holds Employee objects. Using a for-each loop, you will need to add the code to the displayEmployees() method in the provided EmployeePay class that iterates through the ArrayList and displays each employee's name, monthly pay and annual pay. You should call the Employee object's monthlyPay and annualPay methods to get these values. You will also need to implement all of the subclasses. Your output should look something like this: 5416.67 8083.33 Johnson Thomas Olson Lewis Campion Davis Wiley Parsons Monthly Pay: Monthly Pay: Monthly Pay: Monthly Pay: Monthly Pay: Monthly Pay: Monthly Pay: Monthly Pay: 4333.33 1250.00 3000.00 8750.00 585.00 3600.00 Annual Pay: Annual Pay: Annual Pay: Annual Pay: Annual Pay: Annual Pay: Annual Pay: Annual Pay: 71500.00 106700.00 55120.00 15625.00 39000.00 115500.00 7312.50 46800.00 Concepts Inheritance Polymorphism Overview This homework introduces polymorphism and provides additional practice translating UML diagrams into code. Description In this assignment, you will implement the inheritance hierarchy provided below. Notice that the Employee class has annualPay and monthlyPay methods. The annualPay method is also present in the Manager, Staff, FullTime and Part Time classes, while the monthly Pay is present in the SalariedEmployee and HourlyEmployee classes. This will give us our first look at polymorphic behavior with something other than to String. Employee name: String hireYear: int monthlyPay() annual Pay() SalariedEmployee annualSalary:int monthlyPay() HourlyEmployee hoursPerWeek:int hourlyllage:double monthlyPay() Manager annualPay() Staff annual Pay() Full Time annual Pay() Part Time annual Pay ( ) Employee Class Hierarchy Implement the seven classes shown above. For the purposes of this homework. DO NOT add a toString method to any of your classes. The pay calculations should be implemented as follows: Monthly pay: Employee: simply return zero Salaried Employee: annualSalary / 12 Hourly Employee: HoursPerWeek X 4 X hourly Wage Annual pay: Employee: simply return zero Manager: annual salary + 10% bonus Staff: annual salary + 2% bonus per year of service up to 5 years Full Time: 50 weeks of wages + 2 weeks wages as bonus Part Time: 50 weeks of wages (no bonus) Execution The execution class, named EmployeePay, provided here reads this data file (EmployeeData.txt) containing employee information, instantiates the appropriate objects and adds them to an ArrayList that holds Employee objects. Using a for-each loop, you will need to add the code to the displayEmployees() method in the provided EmployeePay class that iterates through the ArrayList and displays each employee's name, monthly pay and annual pay. You should call the Employee object's monthlyPay and annualPay methods to get these values. You will also need to implement all of the subclasses. Your output should look something like this: 5416.67 8083.33 Johnson Thomas Olson Lewis Campion Davis Wiley Parsons Monthly Pay: Monthly Pay: Monthly Pay: Monthly Pay: Monthly Pay: Monthly Pay: Monthly Pay: Monthly Pay: 4333.33 1250.00 3000.00 8750.00 585.00 3600.00 Annual Pay: Annual Pay: Annual Pay: Annual Pay: Annual Pay: Annual Pay: Annual Pay: Annual Pay: 71500.00 106700.00 55120.00 15625.00 39000.00 115500.00 7312.50 46800.00
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
