JAVA的练习有困难....

[复制链接]
查看11 | 回复1 | 2009-3-28 10:54:25 | 显示全部楼层 |阅读模式
近来上课的题目都不太懂....但功课快要交了....希望JAVA高手可以帮帮我啊...!!
a) Create a package payroll.
b) Within the package payroll, create an abstract class Worker .
c) Provide private valuables for recording the name, salary rate and hours worked.
d) Provide a constructor to initialize the name, salary rate and hours worked properties.
e) The Worker class should ensure that its subclasses should have a method
public double computePayment().
f) Create classes HourlyWorker and SalariedWorker and make them to be the subclasses of Worker using inheritance.
g) In HourlyWorker, provide a overwriting method computePayment to compute payment for an hourly worker. As a hourly worker, he gets paid the hourly wage for the actual number of hours worked, and if he worked more than 40 hours, the excess is doubly paid.
h) In SalariedWorker, Provide a overwriting method computePayment to compute payment for an salaried worker. As a salaried worker, he gets paid the hourly wage for 36 hours, no matter what the actual number of hours is.
i) Create a test program that is in another package. This program has a main method and uses an array to store 4 different workers.Finally, using polymorphism to compute payment for each worker and print out the result.
我翻译了中文,可能会有错,但想方便一下大家而巳.
a) 建立了一个PACKAGE名为payroll。
b) ayroll,建立一个CLASS为Worker。
c) 提供私有实例变量去记录的姓名,工资率和工作时间。
d) 提供一个构造函数来初始化的名称,工资率和工作时间属性。
e) 在 Worker应确保其subclasses 应该有一个方法public double computePayment()。
f) 建立一个CLASS叫HourlyWorker和SalariedWorker并使其成为Worker的subclasses使用继承。
g) 在HourlyWorker 里,提供一个overwriting 方法,computePayment,计算每小时工人的薪金。作为HourlyWorker,他会计算实际工作时数的工资,如果他工作超过40小时,多余的是加倍计算。
h) 在SalariedWorker ,提供了一个overwriting 方法,computePayment,来计算computePayment的工薪。作为SalariedWorker,他会计算36小时的工资,无论实际人数小时。
i) 创建一个测试程序,这是另一个package。该程序有一个主要方法,并使用一个数组来存储4种不同的工人。最后,使用多态性来计算每个工人的所得工资并打印出的结果。

回复

使用道具 举报

千问 | 2009-3-28 10:54:25 | 显示全部楼层
is it bcit daytime 1409 lab? I did a similar lab last week, may help you. 19467385,QQ,add me....
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行