Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please divide it into 5 files while maintaining the existing function and output result of this code. 1. main.cpp - int main() keep the content

Please divide it into 5 files while maintaining the existing function and output result of this code. 1. main.cpp - int main() keep the content intact 2. Employee.h - Employee class and function declaration 3. ProductionWorker.h - Employee class and function declaration 4. TeamLeader.h - Employee class and function declaration

5. All.h Definition of Employee, ProductionWorker, TeamLeader class function

If there is a better way to divide into five, please explain it that way. Thank you.

code :

#include #include #include #include

using namespace std;

class Employee { private: string employeeName; string employeeNumber; string hireDate;

public: Employee(); // default constructor Employee(string name, string number, string date); // constructor with parameters void setEmployeeName(string employeeName); // set employee name void setEmployeeNumber(string employeeNumber); // set employee number void setHireDate(string hireDate); // set hire date string getEmployeeName() const; // get employee name string getEmployeeNumber() const; // get employee number string getHireDate() const; // get hire date };

Employee::Employee() { cout << "Please answer some questions about your employees. " << endl; }

// Constructor with parameters Employee::Employee(string name, string number, string date) { employeeName = name; employeeNumber = number; hireDate = date; }

// Set employee name void Employee::setEmployeeName(string name) { employeeName = name; }

// Set employee number void Employee::setEmployeeNumber(string number) { employeeNumber = number; }

// Set hire date void Employee::setHireDate(string date) { hireDate = date; }

// Get employee name string Employee::getEmployeeName() const { return employeeName; }

// Get employee number string Employee::getEmployeeNumber() const { return employeeNumber; }

// Get hire date string Employee::getHireDate() const { return hireDate; }

class ProductionWorker : public Employee { private: int shift; int hourlyPay;

public: ProductionWorker(); // default constructor ProductionWorker(string name, string number, string date, int s, int pay); // constructor with parameters void setShift(int shift); // set shift void setHourlyPay(int pay); // set hourly pay int getShift() const; // get shift int getHourlyPay() const; // get hourly pay };

// Default constructor ProductionWorker::ProductionWorker() { cout << "Your responses will be displayed after all data has been received." << endl; }

// Constructor with parameters ProductionWorker::ProductionWorker(string name, string number, string date, int s, int pay) : Employee(name, number, date) { shift = s; hourlyPay = pay; }

// Set shift void ProductionWorker::setShift(int s) { shift = s; }

// Set hourly pay void ProductionWorker::setHourlyPay(int pay) { hourlyPay = pay; }

// Get shift int ProductionWorker::getShift() const { return shift; }

// Get hourly pay int ProductionWorker::getHourlyPay() const { return hourlyPay; }

class TeamLeader : public ProductionWorker { private: int monthlyBonus; int requiredTrainingHours; int attendedTrainingHours;

public: TeamLeader(); TeamLeader(string name, string number, string date, int s, int pay, int bonus, int reqTrainingHours, int attTrainingHours); void setMonthlyBonus(int bonus); void setRequiredTrainingHours(int hours); void setAttendedTrainingHours(int hours); int getMonthlyBonus() const; int getRequiredTrainingHours() const; int getAttendedTrainingHours() const; };

TeamLeader::TeamLeader() { cout << "Your responses will be displayed after all data has been received." << endl; }

TeamLeader::TeamLeader(string name, string number, string date, int s, int pay, int bonus, int reqTrainingHours, int attTrainingHours) : ProductionWorker(name, number, date, s, pay) { monthlyBonus = bonus; requiredTrainingHours = reqTrainingHours; attendedTrainingHours = attTrainingHours; }

void TeamLeader::setMonthlyBonus(int bonus) { monthlyBonus = bonus; }

void TeamLeader::setRequiredTrainingHours(int hours) { requiredTrainingHours = hours; }

void TeamLeader::setAttendedTrainingHours(int hours) {

attendedTrainingHours = hours; }

int TeamLeader::getMonthlyBonus() const { return monthlyBonus; }

int TeamLeader::getRequiredTrainingHours() const { return requiredTrainingHours; }

int TeamLeader::getAttendedTrainingHours() const { return attendedTrainingHours; }

int main() { string name, number, date; int shift, requiredTrainingHours, attendedTrainingHours; int hourlyPay, monthlyBonus;

// Get employee information cout << "Enter employee name: "; getline(cin, name);

cout << "Enter employee ID: "; getline(cin, number);

cout << "Enter hire date: "; getline(cin, date);

cout << "Enter shift (1 for day, 2 for night): "; cin >> shift;

cout << "Enter pay rate: "; cin >> hourlyPay;

cout << "Enter bonus rate: "; cin >> monthlyBonus;

cout << "Enter training hours: "; cin >> attendedTrainingHours;

cout << "Enter required hours: "; cin >> requiredTrainingHours;

// Create team leader object TeamLeader tl(name, number, date, shift, hourlyPay, monthlyBonus, requiredTrainingHours, attendedTrainingHours);

// Display employee and production worker information cout << "===================================" << endl; cout << "The employee name : " << tl.getEmployeeName() << endl; cout << fixed << setprecision(2) << "The Pay Rate : " << tl.getHourlyPay() << endl; cout << "The employee ID : " << tl.getEmployeeNumber() << endl; cout << "The Hire Date : " << tl.getHireDate() << endl; cout << "Shift : " << (tl.getShift() == 1 ? "Day" : "Night") << endl;

// Display team leader information cout << fixed << setprecision(2) << "Bonus Rate : " << tl.getMonthlyBonus() << endl; cout << "Training hours : " << tl.getAttendedTrainingHours() << endl; cout << "Required hours : " << tl.getRequiredTrainingHours() << endl;

return 0; }

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

Database Marketing The Ultimate Marketing Tool

Authors: Edward L. Nash

1st Edition

0070460639, 978-0070460638

More Books

Students also viewed these Databases questions