COMPLETE THE JAVA CODE BELOW SEE ATTACHED PHOTO FOR THE PROBLEM AND THE OUTPUT
COMPLETE THE JAVA CODE BELOW
SEE ATTACHED PHOTO FOR THE PROBLEM AND THE OUTPUT
class Employee extends Person {
private String companyName;
public Employee(String name,String address,int age,String companyName) {
super(name,address,age);
this.companyName = companyName;
}
public Employee() {
}
public void setCompanyName(String cname){
companyName = cname;
}
public String getCompanyName(){
return companyName;
}
// Override the display method in the Person class
// define earnings as an abstract method with a return type of double
// override the toString() and equals() methods
}
class HourlyEmployee extends Employee
{
private int hoursWorked; //total number of hours worked
private double rate; // rate per hour
public HourlyEmployee(String name,String address,int age,String cName,int hoursWorked,double rate) {
}
public HourlyEmployee(String name,String address,int age,String cName) {
hoursWorked = 0;
rate = 0;
}
// provide the setters and getters of your data members
//earnings is computed by having the product of
//the total number of hours worked and the rate.
// but if the number of hours worked exceeds 40,
// the rate increases to 150% of the current rate.
// (ex. rate=200; 150% = 300)
// override the toString() and equals() methods
}
Step by step
Solved in 4 steps with 2 images