创建测试类 EmployeeTest ,在其 main 方法中分别输出技术员和销售员的姓名和总工资。 给出员工的参考信息:(数据不要求相同) Sales (200125," Tony "32,2000); saleAmount =85 Technician (200153," Paul ",33,3500); hours =160
时间: 2024-03-11 10:47:20 浏览: 124
类的运用 某公司雇员(employee)
4星 · 用户满意度95%
好,下面是EmployeeTest类的代码,用于测试Technician和Sales类的功能:
```
public class EmployeeTest {
public static void main(String[] args) {
Sales sales = new Sales(200125, "Tony", 32, 2000);
Technician technician = new Technician(200153, "Paul", 33, 3500);
System.out.println("Salesperson " + sales.getName() + "'s total salary is " + sales.calculateSalary());
System.out.println("Technician " + technician.getName() + "'s total salary is " + technician.calculateSalary());
}
}
```
在上面的代码中,我们创建了一个Sales对象和一个Technician对象,并调用它们的calculateSalary方法来计算总工资。然后,我们使用getName方法来获取每个职工的姓名,并将姓名和总工资输出到控制台上。根据给出的员工参考信息,输出应该类似于以下内容:
```
Salesperson Tony's total salary is 340125.0
Technician Paul's total salary is 5606.0
```
阅读全文