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

In C++ Design a class named Employee. The class should keep the following inform

ID: 3603395 • Letter: I

Question

In C++

Design a class named Employee. The class should keep the following information in

-Employee name

-Employee number

-Hire date

Write one or more constructors and the appropriate accessor and mutator functions for the class.

Next, write a class named ProductionWorker that is derived from the Employee class. The ProductionWorker class should have member variables to hold the following information:

-Shift (an integer)

-Hourly pay rate (a double)

The workday is divided into two shifts: day and night. The shift variable will hold an integer value representing the shift that the employee works. The day shift is shift 1, and the night shift is shift 2. Write one or more constructors and the appropriate accessor and mutator functions for the class. Demonstrate the classes by writing a program that uses a ProductionWorker object.

Thirdly, create a class TeamLeader that extends the ProductionWorker class. Team leader is an hourly paid production worker who leads a small team. In addition to hourly pay, they earn a fixed monthly bonus. Team leaders are required to attend a minimum number of hours of training per year. This class should have member variables for the monthly bonus amount, the number of  required training hours, and the number of training hours that the team leader has attended. Write one or more constructors and appropirate accessor and mutator functions for this class. Demonstrate by writing a program that uses a TeamLeader object

Lastly, design a ShiftSupervisor class that is derived from the Employee class. A shift supervisor is a salaried employee who supervises a shift and in addition to a salary they earn a yearly bonus when their shift meets production goals. This class should have a member variable that holds the annual salary and member variable that holds the annual production bonus that this shift supervisor has earned. Write one or more constructors and the appropriate accessor and mutator functions for the class. Demonstrate by writing a program that uses a ShiftSupervisor object.

Please use //To describe which function is being implemented in the code.

Explanation / Answer

#include <iostream>

#include <iomanip>

#include <cstring>

using namespace std;

class Employee

{

//variables

private:

char name[30];

int empNum;

string hiredate;

public:

//constructor

Employee(char name[30],int empNum,string hiredate)

{

strcpy(this->name,name);

this->empNum = empNum;

this->hiredate = hiredate;

}

//set and get methods

void setName(char name[30])

{

strcpy(this->name,name);

}

void setEmpNum(int empNum)

{

this->empNum = empNum;

}

void setHiredate(string hiredate)

{

this->hiredate = hiredate;

}

char* getName()

{

return name;

}

int getEmpNum()

{

return empNum;

}

string getHiredate()

{

return hiredate;

}

void display()

{

cout<<" Name: "<<getName();

cout<<" Employee number: "<<getEmpNum();

cout<<" Hire date: "<<getHiredate();

}

};

class ProductionWorker :public Employee

{

private :

int shift;

double hourlyPayRate;

public:

//passing parameters to base class Employee from derived class ProductionWorker

ProductionWorker(char name[30],int empNum,string hiredate,int shift,double hourlyPayRate):Employee(name,empNum,hiredate)

{

this->shift = shift;

this->hourlyPayRate = hourlyPayRate;

}

//get and set functions

void setShift(double shift)

{

this->shift = shift;

}

void setHouryPayRate(double hourlyPayRate)

{

this->hourlyPayRate = hourlyPayRate;

}

double getShift()

{

return shift;

}

double getHourlyPayRate()

{

return hourlyPayRate;

}

void displayDetails()

{

display(); //call to Employee class function

cout<<" Shift: $"<<getShift();

cout<<" Hourly Pay Rate : "<<getHourlyPayRate();

}

};

class TeamLeader : ProductionWorker

{

private:

double monthlyBonus;

int reqTrainingHours;

int attendedHours;

public:

  

TeamLeader(char name[30],int empNum,string hiredate,int shift,double hourlyPayRate,double monthlyBonus,int reqTrainingHours,int attendedHours):ProductionWorker(name,empNum,hiredate,shift,hourlyPayRate)

{

this->monthlyBonus = monthlyBonus;

this->reqTrainingHours = reqTrainingHours;

this->attendedHours = attendedHours;

}

//get and set functions

void setMonthlyBonus(double monthlyBonus)

{

this->monthlyBonus = monthlyBonus;

}

void setReqTrainingHours(int reqTrainingHours)

{

this->reqTrainingHours = reqTrainingHours;

}

void setAttendedHours(int attendedHours)

{

this->attendedHours = attendedHours;

}

double getMonthlyBonus()

{

return monthlyBonus;

}

int getReqTrainingHours()

{

return reqTrainingHours;

}

int getAttendedHours()

{

return attendedHours;

}

void displayDetails()

{

cout<<" Team leader : ";

display(); //call to Employee class function

cout<<" Monthly Bonus : $"<<getMonthlyBonus();

cout<<" Required Training Hours : "<<getReqTrainingHours();

cout<<" Attended Training Hours : "<<getAttendedHours();

}

};

class ShiftSupervisor :public Employee

{

private :

double annualSalary;

double annualProductionBonus;

public:

//passing parameters to base class Employee from derived classShiftSupervisor

ShiftSupervisor(char name[30],int empNum,string hiredate,double annualSalary,double annualProductionBonus):Employee(name,empNum,hiredate)

{

this->annualSalary = annualSalary;

this->annualProductionBonus = annualProductionBonus;

}

//get and set functions

void setAnnualSalary(double annualSalary)

{

this->annualSalary = annualSalary;

}

void setAnnualProductionBonus(double annualProductionBonus)

{

this->annualProductionBonus = annualProductionBonus;

}

double getAnnualSalary()

{

return annualSalary;

}

double getAnnualProductionBonus()

{

return annualProductionBonus;

}

void displayDetails()

{

display(); //call to Employee class function

cout<<" Annual Salary: $"<<getAnnualSalary();

cout<<" Annual Production Bonus: $"<<getAnnualProductionBonus();

}

};

int main()

{

TeamLeader tl("Andrew Johnson",676,"10/21/2010",1,7.8,500.50,40,25);

  

  

cout<<fixed<<setprecision(2); //use manipulator functions

tl.displayDetails();

  

ShiftSupervisor ss("John Doe",859,"7/24/2014",75000,15000);

cout<<fixed<<setprecision(2); //use manipulator functions

ss.displayDetails();

return 0;

}

output: