inheritance - Java compiler error: "cannot find symbol constructor .."? -


i'm writing code employee, manager, hourly worker class assignment i've hit problem can't figure out, following code employee followed hourly worker. problem hourly worker won't compile, it's giving "cannot find symbol constructor employee" error when try compile (employee class compiiles without issue. suggestions please? think i've been staring @ long can no longer see problem! thanks. pieter.

employee class -

public class employee {    public string firstname;    public string lastname;    public double hourlyrate;    final static double normal_workweek = 37.5;     public employee(string firstname, string lastname, double hourlyrate)    {        setfirstname(firstname);        setlastname(lastname);        sethourlyrate(hourlyrate);     }     //accessor , mutator methods employee's first name.     public string getfirstname()     {         return firstname;     }      public void setfirstname(string firstname)     {         firstname = firstname;     }    //accessor , mutator methods employee's last name.      public string getlastname()     {         return lastname;     }      public void setlastname(string lastname)     {         lastname = lastname;     }     //access , mutator methods employee's hourly rate.     public double gethourlyrate()     {         return hourlyrate;     }     public void sethourlyrate(double hourlyrate)     {     //if user input valid, update employee's hour rate newly input value.      if(hourlyrate > 0)     {       hourlyrate = hourlyrate;         }       //otherwise prevent hour rate greater 0 being overwritten          else if(hourlyrate <=0)         {     if(hourlyrate <= 0)    {                        hourlyrate = 0;             }    decorateconsole();    //alert user mistake.   system.out.println("error ! ! ! - attempt set employee " + this.firstname + " " + this.lastname + "'s hourly rate 0 detected.\n");    decorateconsole();    }    }   public void printstate()  {    decorateconsole();    system.out.println("[first name] = " + firstname + " [last name] = " + lastname + " [hourly rate] = " + hourlyrate + "\n");    decorateconsole();   }   public void decorateconsole()  {    system.out.println("+-< employee info >-------------------------------------------------------------------------------------------------------------------------+\n");   } 

hourly worker class -

public class hourlyworker extends employee {    private double wage;    private double hours;     public hourlyworker(string firstname, string lastname, double hourlywage, double hoursworked)    {        super(firstname, lastname);        this.wage = wage;        this.hours = hours;     }      public void setwage (double hourlywage)     {        this.wage = wage;     }     public void getwage()     {         return wage;     }     public void sethours (double hours)     {         this.hours = hours;     }     public double gethours()     {         return hours;     }     } 

you don't have employee constructor 2 parameters:

super(firstname, lastname); 

try using:

super(firstname, lastname, 0.0); 

edit per tony request, here's more detailed explanation.

with super(firstname, lastname); you're invoking ( trying invoke ) constructor in class employee has 2 string parameters.

reviewing employee class definition, see don't have such constructor, have 1 3 parameters:

public employee(string firstname, string lastname, double hourlyrate) 

so, solution invoke constructor instead. since don't have default value hourlyrate can use 0.0 double.

other alternative create 2 parameter constructor in employee class

public employee(string firstname, string lastname ) 

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -