Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. In a particular factory, a team leader is an hourly paid production worker th

ID: 3808625 • Letter: 1

Question

1. In a particular factory, a team leader is an hourly paid production worker that 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 .The Team leader should have fields for the monthly bonus amount, the required numbers of training hours and the number of training hours the team leader has attended. Write one or more constructor and the appropriate accessor and mutator methods for the class. Demonstrate the class by writing a program that uses a TeamLeader Object. 1. In a particular factory, a team leader is an hourly paid production worker that 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 .The Team leader should have fields for the monthly bonus amount, the required numbers of training hours and the number of training hours the team leader has attended. Write one or more constructor and the appropriate accessor and mutator methods for the class. Demonstrate the class by writing a program that uses a TeamLeader Object.

Explanation / Answer

#include <iostream>
#include <iomanip>
#include <string>
using namespace std;

class Employee
{
private:
string name; // Employee name
string number; // Employee number
string hireDate; // Hire date

public:
Employee()
{ name = ""; number = ""; hireDate = ""; }

Employee(string aName, string aNumber, string aDate)
{ name = aName; number = aNumber; hireDate = aDate; }

void setName(string n)
{ name = n; }

void setNumber(string num)
{ number = num; }

void setHireDate(string date)
{ hireDate = date; }

string getName() const
{ return name; }

string getNumber() const
{ return number; }

string getHireDate() const
{ return hireDate; }
};

class ProductionWorker : public Employee
{
private:
int shift; // The worker's shift
double payRate; // The worker's hourly pay rate

public:
ProductionWorker() : Employee()
{ shift = 0; payRate = 0.0; }

ProductionWorker(string aName, string aNumber, string aDate,
int aShift, double aPayRate) : Employee(aName, aNumber, aDate)
{ shift = aShift; payRate = aPayRate; }

void setShift(int s)
{ shift = s; }

void setPayRate(double r)
{ payRate = r; }

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:
};
void displayInfo(ProductionWorker);
void displayInfo(TeamLeader);

int main()
{
ProductionWorker pw("John Jones", "123", "1/1/2006", 2, 18.00);
displayInfo(pw);
/* remove the comment to enable
TeamLeader leader("John Jones", "123", "1/1/2006", 2, 18.00,
500.0, 20.0, 12.5);
displayInfo(leader);
*/
return 0;
}
void displayInfo(ProductionWorker e)
{
cout << setprecision(2) << fixed << showpoint;
cout << "Name: "
<< e.getName() << endl;
cout << "Employee number: "
<< e.getNumber() << endl;
cout << "Hire date: "
<< e.getHireDate() << endl;
cout << "Shift: "
<< e.getShiftName() << endl;
cout << "Shift number: "
<< e.getShiftNumber() << endl;
cout << "Pay rate: "
<< e.getPayRate() << endl;
}

void displayInfo(TeamLeader e)
{
/* enable this section to print
cout << setprecision(2) << fixed << showpoint;
cout << "Name: "
<< e.getName() << endl;
cout << "Employee number: "
<< e.getNumber() << endl;
cout << "Hire date: "
<< e.getHireDate() << endl;
cout << "Shift: "
<< e.getShiftName() << endl;
cout << "Shift number: "
<< e.getShiftNumber() << endl;
cout << "Pay rate: "
<< e.getPayRate() << endl;
cout << "Monthly bonus: $"
<< e.getMonthlyBonus() << endl;
cout << setprecision(1);
cout << "Required training hours: "
<< e.getRequiredTraining() << endl;
cout << "Completed training hours: "
<< e.getCompletedTraining() << endl;
*/
}