Question
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
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
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
double getBonus() const; double getrTraining() const; double getcTraining() const;
};
#endif;
Employee.cpp:
#include "Employee.h" #include
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
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
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
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
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