Hey guys! So the error I'm getting is "cannot reference hoursWorked before supertype constructor has been called". I've just recently learned about using abstract, extends, and the keyword "super". What should I do in order to get rid of the error? Am I missing something? Here's my code so far:
Employee.java
public abstract class Employee {
private String name;
public Employee(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public double computeTax(){
double amount = 0;
return amount;
}
}
HourlyEmployee.java
public abstract class HourlyEmployee extends Employee{
protected double hoursWorked;
public HourlyEmployee(String name, double hoursWorked) {
super(name);
this.hoursWorked = hoursWorked;
}
public double getHoursWorked() {
return hoursWorked;
}
public void setHoursWorked(double hoursWorked) {
this.hoursWorked = hoursWorked;
}
Janitor.java
public class Janitor extends HourlyEmployee{
private double hourlyRate;
public Janitor(String name, int hourlyRate) {
super(name, hoursWorked);
this.hourlyRate = hourlyRate;
}
}
Lawyer.java
public class Lawyer extends HourlyEmployee {
private double consultationFee;
public Lawyer(String name, double consultationFee) {
super(name, hoursWorked);
this.consultationFee = consultationFee;
}
}
Thanks for taking time to help me out!