该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
The files Firm.java, Staff.java, StaffMember.java, Volunteer.java, Employee.java, Executive.java, and Hourly.java constitute a program that illustrates inheritance and polymorphism. In this exercise you will add one more employee type to the class hierarchy. The employee will be an hourly employee who also earns a commission on sales. Hence the class, which we'll name Commission, will be derived from the Hourly class.
NOTE: For this assignment, you should ONLY create/modify the Commission.java and Staff.java files! The other files are just support files for the rest of the program.
Create a new class named Commission with the following features:
* It extends the Hourly class.
* It has two instance variables (in addition to those that it inherits from the Hourly class): one is the total sales the employee has made (type double) and the second is the commission rate for the employee. The commission rate will be type double and will represent the percent (in decimal form) commission the employee earns on sales (so .2 would mean the employee earns 20% commission on sales).
* The constructor takes 6 parameters: the first 5 are the same as for Hourly (name, address, phone number, social security number, hourly pay rate) and the 6th is the commission rate for the employee. The constructor should call the constructor of the parent class (via super()) with the first 5 parameters and then use the 6th to set the commission rate.
* One additional method is needed: public void addSales (double totalSales), which adds the parameter to the instance variable representing total sales.
* The pay() method must call the pay method of the parent class to compute the pay for hours worked then add to that the pay from commission on sales. (See the pay() method in the Executive class.) The total sales should be set back to 0 (note: you don't need to set the value of hoursWorked back to 0 — why not?).