public class TestFinals { public static void main(String[] args) { HourlyEmployee lis = new HourlyEmployee("lisi", 6, 8, 30); lis.setHours(8); SalariedEmployee zs = new SalariedEmployee("zhangsan", 8, 6000); SalesEmployee wangw = new SalesEmployee("wangwu", 1, 100, 2.5); Finals fal = new Finals(); fal.printSalary(lis, 3); fal.printSalary(zs, 3); fal.printSalary(wangw, 3); Employee[] emp = new Employee[3]; emp[0] = new HourlyEmployee("lisi", 6, 8, 30); emp[1] = new SalariedEmployee("zhangsan", 8, 6000); emp[2] = new SalesEmployee("wangwu", 1, 100, 2.5); fal.printSalary(emp, 3); } }将这个代码修改正确
时间: 2023-06-25 12:06:45 浏览: 89
public class TestFinals {
public static void main(String[] args) {
HourlyEmployee lis = new HourlyEmployee("lisi", 6, 8, 30);
lis.setHours(8);
SalariedEmployee zs = new SalariedEmployee("zhangsan", 8, 6000);
SalesEmployee wangw = new SalesEmployee("wangwu", 1, 100, 2.5);
Finals fal = new Finals();
fal.printSalary(lis, 3);
fal.printSalary(zs, 3);
fal.printSalary(wangw, 3);
Employee[] emp = new Employee[3];
emp[0] = new HourlyEmployee("lisi", 6, 8, 30);
emp[1] = new SalariedEmployee("zhangsan", 8, 6000);
emp[2] = new SalesEmployee("wangwu", 1, 100, 2.5);
fal.printSalary(emp, emp.length); // 修改此处,使用数组长度作为参数
}
}
阅读全文