美国大学java_谁能帮个忙啊..美国大学里的JAVA题目...最后一部分无法完成..

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

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?).

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值