Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Design and implement the following classes: (A) An abstract class Employee that

ID: 3530991 • Letter: D

Question

Design and implement the following classes: (A) An abstract class Employee that represents a generic employee. Include methods to retrieve information about the employee. (B) A subclass of Employee called HourlyEmployee that describes an employee that gets paid by the hour. Include a public method called pay that returns the pay of the employee for that month, and other relevant methods. (C) A subclass of Employee called NonHourlyEmployee that describes an employee who gets paid a fixed salary every month. Include a public method called pay that returns the pay of the employee for that month. Include any other relevant methods.

Explanation / Answer

public abstract class Employee {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public abstract String getEmployeeInfo();
}



public class HourlyEmployee extends Employee {

double payRate = 15;
@Override
public String getEmployeeInfo() {

return "Emp name " + getName() + " monthly pay: " + pay(240);
}
public double pay(int hours) {
return hours * payRate;
}

}



public class NonHourlyEmployee extends Employee {

@Override
public String getEmployeeInfo() {

return "Emp name " + getName() + " monthly pay: " + pay();
}
public double pay() {
return 30000;
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote