| 
Write an abstract class Worker, two concrete subclassesHourlyWorkerandSalariedWorker, and a test programTestWorker. Each of these classes is described below. 
The abstract Workerclass has a name field and a salary rate (in dollars per hour) field. TheWorkerclass has an abstract instance methodcomputeWeeklyPay(int hours)(each subclass ofWorkerwill have its own way of computing weekly pay). TheWorkerclass should have appropriate constructors, appropriate (concrete) set and get methods for the name and salary fields, and it should also have a (concrete)toStringmethod that returns the name and salary rate in an appropriate string. 
The HourlyWorkerclass has abooleaninstance field calledisUnionMemeberand aStringinstance field calledunionName(which should be set tonullifisUnionMemeberisfalse). TheHourlyWorkerclass has acomputeWeeklyPay(int hours)method that implements the same method from the super class (an hourly worker gets paid for the actual number of hours worked, with overtime over 40 hours paid at time and a half). TheHourlyWorkerclass should have appropriate constructors (that make use of the super class constructors), appropriate set and get methods, and it should also have atoStringmethod that both overrides and calls thetoStringmethod in the super class, and that returns the name, salary rate, and union status in an appropriate string. 
The SalariedWorkerclass has anintinstance field calledsubordinatesthat records the number of workers that the salaried worker manages. TheSalariedWorkerclass has acomputeWeeklyPay(int hours)method that implements the same method from the super class (a salaried worker always gets paid for 40 hours, no matter what the actual hours worked is). TheSalariedWorkerclass should have appropriate constructors (that make use of the super class constructors), appropriate set and get methods, and it should also have atoStringmethod that both overrides and calls thetoStringmethod in the super class, and that returns the name, salary rate, and number of subordinates in an appropriate string. 
Write a test class called TestWorker. It should create an array of typeWorkerand fill it with someHourlyWorkerand someSalariedWorkerobjects. Then the program should loop through the array and use polymorphism to compute the pay and print out all of the information for each object in the array. The test class should also show that your constructor, get, and set methods all work. 
When you are done you will have four program files, Worker.java,HourlyWorker.java,SalariedWorker.javaandTestWorker.java. Put these four files together into one zip file. 
This assignment is due Monday, December 1.
 
 |