Absract class and its sub clases
hi,
this is the coding for abstract class Worker... Can anyone help me
with the codes for the subclass ParttimeWorker as the code below the
abstract class doesnt really work while i compile.
public abstract class Worker
{
protected String name;
protected double salaryRate;
public String getName()
{
return name;
}
public double getsalaryRate()
{
return salaryRate;
}
public void setName(String n)
{
Name = n;
}
public void setsalaryRate(double sal)
{
SalaryRate = sal;
}
public abstract double weeklySalary();
}
public class ParttimeWorker extends Worker
{
private double SalaryRate;
char Type;
int NormalHours;
int ExtraHours;
private double Salary;
public ParttimeWorker(String SalaryRate,char Type,int NormalHours,int
ExtraHours);
{
this.SalaryRate = SalaryRate;
this.Type = Type;
this.NormalHours = NormalHours;
this.ExtraHours = ExtraHours;
}
public double getSalaryRate()
{
return SalaryRate;
}
public char getType()
{
return Type;
}
public int getNormalHours()
{
return NormalHours;
}
public int getExtraHours()
{
return ExtraHours;
}
public void setSalaryRate(double s)
{
SalaryRate = s;
}
public void setType(char t)
{
Type = t;
}
public void setNormalHours(int n)
{
NormalHours = n;
}
public void setExtraHours(int e)
{
ExtraHours = e;
}
public void calculate()
{
if (this.NormalHours > 40)
this.Salary = (this.ExtraHours * 1.5) + (this.NormalHours *
this.SalaryRate);
else
this.Salary = this.NormalHour * this.SalaryRate;
}
}