Categories
Development

My super is not working even though I think its set up right

I’m doing an assignment for school and im implementing a super but its not working yet i feel its done right. anyone have any idea why my super gives me a syntax error. It tells me “The Constructor Employee(String, String, String) is undefined yet it is though.

Here’s my employee class that my other classes extend off of which have this super error.

/**
* Abstract class Employee - write a description of the class here
*
* @author (your name here)
* @version (version number or date here)
*/
public abstract class Employee
{
   private String firstName;
   private String lastName;
   private String socialSecurityNumber;

   public Employee(String first, String last, String ssn)
   {
       firstName=first;
       lastName=last;
       socialSecurityNumber=ssn;
   }

   public abstract double earnings();

   public String toString()
   {
       return("\n"+firstName+" "+lastName+
               "\nsocial security number: "+ socialSecurityNumber);
   }
}

Here’s one class with the super that gives me the issue.

public class SalariedEmployee extends Employee{
    private double weeklySalary;

    // four-argument constructor
    public SalariedEmployee(String first, String last, String ssn, double salary) {
        super(first, last, ssn); // pass to Employee constructor
        setWeeklySalary(salary); // validate and store salary
    } // end four-argument SalariedEmployee constructor

    // set salary
    public void setWeeklySalary(double salary) {
        weeklySalary = salary < 0.0 ? 0.0 : salary;
    } // end method setWeeklySalary

    // return salary
    public double getWeeklySalary() {
        return weeklySalary;
    } // end method getWeeklySalary

    // calculate earnings; override abstract method earnings in Employee
    public double earnings() {
        return getWeeklySalary();
    } // end method earnings

    // return String representation of SalariedEmployee object
    public String toString() {
        return String.format("salaried employee: %s\n%s: $%,.2f",
            super.toString(), "weekly salary", getWeeklySalary());
    } // end method toString
 } // end class SalariedEmployee

My other two classes like i said have the same issue so i don’t think it would be necessary to post them but any help is greatly appreciated!

Leave a Reply

Your email address will not be published. Required fields are marked *