Question
How to fix this two programs and demonstrate class by writing a program that uses a TeamLeader object class ProductionWorker : public Employee { private:
How to fix this two programs and demonstrate class by writing a program that uses a TeamLeader object
class ProductionWorker : public Employee
{
private:
int shift; // The worker's shift
double payRate; // The worker's hourly pay rate
public:
// Default constructor
ProductionWorker() : Employee()
{ shift = 0; payRate = 0.0; }
// Constructor
ProductionWorker(string aName, string aNumber, string aDate,
int aShift, double aPayRate) : Employee(aName, aNumber, aDate)
{ shift = aShift; payRate = aPayRate; }
// Mutators
void setShift(int s)
{ shift = s; }
void setPayRate(double r)
{ payRate = r; }
// Accessors
int getShiftNumber() const
{ return shift; }
string getShiftName() const
{ if (shift == 1)
return "Day";
else if (shift == 2)
return "Night";
else
return "Invalid";
}
double getPayRate() const
{ return payRate; }
}
class TeamLeader : public ProductionWorker
{
private:
double monthlyBonus; // Monthly bonus amount
double requiredTraining; // Required training hours
double completedTraining; // Completed training hours
public:
// Default constructor
TeamLeader() : ProductionWorker()
{ monthlyBonus = 0.0; requiredTraining = 0.0;
completedTraining = 0.0;
}
// Constructor
TeamLeader(string aName, string aNumber, string aDate,
int aShift, double aPayRate, double aBonus, double aReqTraining,
double aCompTraining) :
ProductionWorker(aName, aNumber, aDate, aShift, aPayRate)
{ monthlyBonus = aBonus;
requiredTraining = aReqTraining;
completedTraining = aCompTraining;
}
// Mutators
void setMonthlyBonus(double bonus)
{ monthlyBonus = bonus; }
void setRequiredTraining(double rt)
{ requiredTraining = rt; }
void setCompletedTraining(double ct)
{ completedTraining = ct; }
// Accessors
double getMonthlyBonus() const
{ return monthlyBonus; }
double getRequiredTraining() const
{ return requiredTraining; }
double getCompletedTraining() const
{ return completedTraining; }
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started