package CompanyEmployees;
public class DoEmployeePayroll {
public static void main(String args[]) {
FullTimeEmployee ftEmployee = new FullTimeEmployee();
ftEmployee.setName("Barry Burd");
ftEmployee.setJobTitle("CEO");
ftEmployee.setWeeklySalary(5000.00);
ftEmployee.setBenefitDeduction(500.00);
ftEmployee.cutCheck(ftEmployee.findPaymentAmount());
System.out.println();
PartTimeEmployee ptEmployee = new PartTimeEmployee();
ptEmployee.setName("Steve Surace");
ptEmployee.setJobTitle("Driver");
ptEmployee.setHourlyRate(7.53);
ptEmployee.cutCheck(ptEmployee.findPaymentAmount(10));
}
}
package CompanyEmployees;
import static java.lang.System.out;
public class Employee {
private String name;
private String jobTitle;
public void setName(String nameIn) {
name = nameIn;
}
public String getName() {
return name;
}
public void setJobTitle(String jobTitleIn) {
jobTitle = jobTitleIn;
}
public String getJobTitle() {
return jobTitle;
}
public void cutCheck(double amountPaid) {
out.printf("Pay to the order of %s ", name);
out.printf("(%s) ***$", jobTitle);
out.printf("%,.2f\n", amountPaid);
}
}
package CompanyEmployees;
public class PartTimeEmployee extends Employee {
private double hourlyRate;
public void setHourlyRate(double rateIn) {
rateIn = hourlyRate;
}
public double getHourlyRate() {
return hourlyRate;
}
public double findPaymentAmount(int hours) {
return hourlyRate * hours;
}
}
我计算了全职员工,但它不是合适的兼职时间。付款应为75.30,但输出0.00。
答案 0 :(得分:1)
你已经改变了这里的论点
private double hourlyRate;
public void setHourlyRate(double rateIn) {
rateIn = hourlyRate;
}
应该是
public void setHourlyRate(double rateIn) {
this.hourlyRate = rateIn;
}