Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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 number of training hours and the number of training hours the team leader has attended. Write one or more constructors and the appropriate accessor and mutator methods for the class. Demonstrate the class by writing a program that uses a TeamLeader Object.

Written code:

Employee.h:

#pragma once #ifndef EMPLOYEE_H #define EMPLOYEE_H #include #include using namespace std; class Employee { private: string name; int number; string hData; public: Employee(); Employee(string, int, string);

void setName(string); void sethData(string); void setNumber(int);

string getName() const; int getNumber() const; string gethData() const;

}; #endif

productionWorker.h:

#pragma once #ifndef PRODUCTIONWORKER_H #define PROCTIONWORKER_H #include using namespace std; class productionWorker: public Employee { private: int shift; double pay; public: productionWorker(); productionWorker(string, int, string, int, double);

void setShift(int s); void setPay(double p);

int getShift(); double getPay(); string getShiftName() const; };

#endif

teamLeader.h:

#pragma once #ifndef TEAMLEADER_H #define TEAMLEADER_H #include using namespace std; class teamLeader:public productionWorker { private: double bonus; double rTraining; double cTraining; public: void setBonus(double b); void setrTraining(double r); void setcTraining(double c);

double getBonus() const; double getrTraining() const; double getcTraining() const;

};

#endif;

Employee.cpp:

#include "Employee.h" #include #include using namespace std; Employee::Employee() { name = ""; number = 0; hData = ""; }

Employee::Employee(string n, int num, string data) { name = n; number = num; hData = data; } void Employee::setName(string n) { name = n; } void Employee::setNumber(int n) { number = n; } void Employee::sethData(string n) { hData = n; } string Employee::getName() const { return name; } int Employee::getNumber() const { return number; } string Employee::gethData() const { return hData; }

productionWorker.cpp:

#include "productionWorker.h" #include #include #include "Employee.h" using namespace std;

productionWorker::productionWorker() { shift = 0; pay = 0; } productionWorker::productionWorker(string n, int num, string d, int s, double p ) { shift = s; pay = p; } void productionWorker:: setShift(int s) { shift = s; } void productionWorker:: setPay(double p) { pay = p; }

int productionWorker::getShift() { return shift; } double productionWorker::getPay() { return pay; } string productionWorker:: getShiftName() const { if (shift == 1) return "Day"; else if (shift == 2) return "Night"; else return "Error input"; }

teamLeader.cpp:

#include "teamLeader.h" #include #include"productionWorker.h" using namespace std;

void teamLeader::setBonus(double b) { bonus = b; } void teamLeader::setcTraining(double c) { cTraining = c; } void teamLeader::setrTraining(double r) { rTraining = r; }

double teamLeader::getBonus() const { return bonus; } double teamLeader::getcTraining() const { return cTraining; } double teamLeader::getrTraining() const { return rTraining; }

Source.cpp:

#include #include #include "Employee.h" #include "productionWorker.h" #include "teamLeader.h" using namespace std; void displayT(teamLeader); int main() {

teamLeader leader("K", 22, "3/6/2020", 1, 11, 666, 23, 12.1); displayT(leader);

system("pause"); return 0; } void displayT(teamLeader e) { cout << "Name: " << e.getName() << endl; cout << "Employee number: " << e.getNumber() << endl; cout << "Hire date: " << e.gethData() << endl; cout << "Shift: " << e.getShiftName() << endl; cout << "Shift number: " << e.getShift() << endl; cout << "Pay rate: " << e.getPay() << endl; cout << "Monthly bonus: " << e.getBonus() << endl; cout << "Required training hours: " << e.getrTraining() << endl; cout << "Completed training hours: " << e.getcTraining() << endl; }

Don't know why it shows an error on line 11 of Source.cpp.

Language: c++

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

2. What recommendations will you make to the city council?

Answered: 1 week ago

Question

What do Dimensions represent in OLAP Cubes?

Answered: 1 week ago