Question: // Please follow the instructions and solve it by C++. Thank You. In a particular factory, a team leader is an hourly paid production worker

// Please follow the instructions and solve it by C++. Thank You.

In a particular factory, a team leader is an hourly paid production worker who leads a small team. In addition to hourly pay, team leaders earn a fixed monthly bonus. Team leaders are required to attend a minimum number of hours of training per year.

Design a TeamLeader class that extends the ProductionWorker class you designed in previous Lab. The TeamLeader class should have member variables for

  • the monthly bonus amount,
  • the required number of training hours, and
  • the number of training hours that the team leader has attended.

Write one or more constructors and the appropriate accessor and mutator functions for the class. Demonstrate the class by writing a program that uses a TeamLeader object.

///////// ProductionWorker Code /////////////

#include

#include

#include

using namespace std;

class Employee

{

protected:

string empName;

int empNum;

string hireDate;

public:

Employee()

{

}

Employee(string empName, int empNum, string hireDate)

{

this->empName = empName;

this->empNum = empNum;

this->hireDate = hireDate;

}

string getEmpName()

{

return empName;

}

void setEmpName(string empName)

{

this->empName = empName;

}

int getEmpNum()

{

return empNum;

}

void setEmpNum(int empNum)

{

this->empNum = empNum;

}

string getHireDate()

{

return hireDate;

}

void setHireDate(string hireDate)

{

this->hireDate = hireDate;

}

string toString();

};

string Employee::toString()

{

stringstream ss;

ss << "Employee Name: " << empName << endl;

ss << "Number: " << empNum << endl;

ss << "Hire Date :" << hireDate << endl;

return ss.str();

}

class ProductionWorker : public Employee

{

protected:

int shift;

double hourlyPayRate;

public:

ProductionWorker();

ProductionWorker(string empName, int empNum, string hireDate, int shift, double payRate);

string toString();

int getShift()

{

return shift;

}

void setShift(int shift)

{

this->shift = shift;

}

double getHourlyPayRate()

{

return hourlyPayRate;

}

void setHourlyPayRate(double hourlyPayRate)

{

this->hourlyPayRate = hourlyPayRate;

}

};

string ProductionWorker::toString()

{

cout << Employee::toString();

stringstream ss;

if (shift == 1)

ss << "Shift : day" << endl;

else if (shift == 2)

ss << "Shift : night" << endl;

ss << "Shift Number :" << shift << endl;

ss << "Hourly Payrate: " << hourlyPayRate << endl;

return ss.str();

}

ProductionWorker::ProductionWorker()

{

}

ProductionWorker::ProductionWorker(

string empName, int empNum, string hireDate, int shift, double payRate)

: Employee(empName, empNum, hireDate)

{

this->shift = shift;

this->hourlyPayRate = payRate;

}

int main()

{

ProductionWorker pw("John James", 123, "2/28/2020", 2, 18.00);

cout << pw.toString();

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!