C# Implement inherited abstract member
I am trying to inherit abstract members from a derived class and it is not
working. I have set the class as abstract such as
public abstract class Employee
and I have the class I have set to derived the members as
public class Hourly : Employee
but it will not inherit the pay scale in the derived class, which I have
set as
public double CalculateWeeklyPay(double Hours, double Wage)
{
return Hours * Wage;
}
Can anyone inform me what I am doing wrong
This is my entire Hourly class
public class Hourly : Employee
{
private double MIN_WAGE = 10;
private double MAX_WAGE = 75;
private double MIN_HOURS = 0;
private double MAX_HOURS = 50;
private double TAX_RATE = .82;
double wage;
double hours;
string category;
public Hourly(string employeeType)
{
Wage = MIN_WAGE;
Hours = MIN_HOURS;
}
public Hourly(double wage, double hours, string category)
: base()
{
Wage = wage;
Hours = hours;
Category = category;
}
public Hourly(string firstname, string lastname, char gender, int
dependents, double annualsalary, Benefits employeeBenefits, double
wage, double hours, string category)
{
Wage = wage;
Hours = hours;
Category = category;
}
public double Wage
{
get { return wage; }
set
{
if (value > MIN_WAGE & value < MAX_WAGE)
wage = value;
else if (value < MIN_WAGE)
wage = MIN_WAGE;
else
wage = MAX_WAGE;
AnnualSalary = CalculateWeeklyPay() * 52;
}
}
public double Hours
{
get { return hours; }
set
{
if (value > MIN_HOURS & value < MAX_HOURS)
hours = value;
else if (value < MIN_HOURS)
hours = MIN_HOURS;
else
hours = MAX_HOURS;
}
}
public string Category
{
get { return category; }
set
{
if (String.IsNullOrEmpty(value))
category = "Not specified";
else if (value == "temporary")
category = value;
else if (value == "part time")
category = value;
else if (value == "full time")
category = value;
else
category = "Invalid entry";
}
}
// Pay method
public double CalculateWeeklyPay(double Hours, double Wage)
{
return Hours * Wage;
}
public override string ToString()
{
string output;
output = "\n============ Employee Information ============";
output += "\n\t Type:\t" + employeeType;
output += "\n\t Name:\t" + firstName + " " + lastName;
output += "\n\t Gender:\t" + gender;
output += "\n\t Dependents:\t" + dependents;
output += "\n\tAnnual Salary:\t" + annualSalary.ToString("C2");
output += "\n\t Weekly Pay:\t" +
CalculateWeeklyPay().ToString("C2");
output += "\n\t" + employeeBenefits.ToString();
output = "\n\t Hours:\t" + hours;
output += "\n\t Wage:\t" + wage;
output += "\n\t Category:\t" + category;
return output;
}
}
}
No comments:
Post a Comment