【发布时间】:2012-02-07 22:35:48
【问题描述】:
好吧,假设我有一个抽象的 Employee 类,3 个类继承自
Employee(Commission, Salary, and Hourly)
员工包括
name
employeeNumber
gender
它下面的内容包括getHourlyWage 或getSalary。然后我有一个带有菜单的驱动程序类,其中包含供用户选择的选项。最后我有一个EmployeeManager 类。
在 Driver 类中,按名称对所有员工进行排序的方法之一是这样调用的:
EmployeeManager em = new EmployeeManager();
em.sortName();
现在我在 EmployeeManager 类中做什么? 首先我制作了数组:
private Employee[] employees = new Employee[100];
那么我将如何对它进行排序,或者首先我如何使用调用的方法添加员工:
addEmployee(int si, String first, char g, double amount)
int si = 1 if the employee is a salary,
2 if the employee is hourly,
3 if commission
string first = name
char g = gender
double amount= wage, salary, or rate-depends on what kind of employee.
您的帮助将不胜感激!!
我认为我的员工、薪水、小时工、佣金和司机都是正确的。我只是不知道如何将它们与这个 EmployeeManager 联系起来。
【问题讨论】:
-
请展示您已经完成的工作并提出具体问题。
-
这些答案是否有用? 0 反馈很难确定您的问题。
标签: java arrays sorting methods polymorphism