Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The classes in this lab describe a superclass named EmployeePerson and two derived classes, EmployeeManager and EmployeeStaff, each of which extends the EmployeePerson class. The

The classes in this lab describe a superclass named EmployeePerson and two derived classes, EmployeeManager and EmployeeStaff, each of which extends the EmployeePerson class. The main program creates objects of type EmployeeManager and EmployeeStaff and prints those objects. Specifications Define the EmployeeManager and EmployeeStaff classes in EmployeeManager.cpp and EmployeeStaff.cpp respectively. Make the EmployeeStaff class override the EmployeePerson class' PrintInfo function and print all the fields from the EmployeeStaff class. Make the EmployeeManager class override the EmployeePerson class' printInfo function and print all the fields from the EmployeeManager class. Run the program and verify the output includes the manager and staff information. Required Employee interfaces EmployeePerson.h and EmployeePerson.cpp contain the EmployeePerson class declaration and definition. EmployeeManager.h and EmployeeStaff.h contain the EmployeeManager and EmployeeStaff class declarations. Use these to create the class definitions in EmployeeManager.cpp and EmployeeStaff.cpp. The EmployeePerson.h, EmployeePerson.cpp, EmployeeManager.h, and EmployeeStaff.h files cannot be changed. The main() function The main() function to test your classes is in EmployeeMain.cpp and cannot be changed. For the main() function given, the output is: Name: Michele, Department: Sales, Birthday: 03-03-1975, Salary: 70000, Staff managed: 25 Name: Bob, Department: Sales, Birthday: 02-02-1980, Salary: 50000, Manager: Michele Code cannot change: Employee Main.Cpp #include #include #include "EmployeePerson.h" #include "EmployeeManager.h" #include "EmployeeStaff.h" using namespace std; int main() { // Create the objects EmployeeManager manager(25); EmployeeStaff staff1("Michele"); // Load data into the objects using the Person class function manager.SetData("Michele", "Sales", "03-03-1975", 70000); staff1.SetData ("Bob", "Sales", "02-02-1980", 50000); // Display the objects manager.PrintInfo(); staff1.PrintInfo(); return 0; } Employee.Staff.h #ifndef EMPLOYEESTAFF_H #define EMPLOYEESTAFF_H #include #include "EmployeePerson.h" using namespace std; class EmployeeStaff : public EmployeePerson { public: EmployeeStaff(); EmployeeStaff(string reportsTo); string GetManagerName(); void PrintInfo(); private: string managerName; }; #endif EmployyPerson.h #ifndef EMPLOYEEPERSON_H #define EMPLOYEEPERSON_H #include #include using namespace std; class EmployeePerson { public: EmployeePerson(); EmployeePerson(string empFullName, string empDepartmentCode, string empBirthday, int empAnnualSalary); void SetData(string empFullName, string empDepartmentCode, string empBirthday, int empAnnualSalary); void PrintInfo(); protected: string fullName; // Format: last name, first name string departmentCode; string birthday; int annualSalary; }; #endif EmployeePerson.CPP #include #include #include "EmployeePerson.h" using namespace std; // Default constructor. Set protected member variables to the empty string or 0 EmployeePerson::EmployeePerson() { fullName = ""; departmentCode = ""; birthday = ""; annualSalary = 0; } // *********************************************************************** // Constructor with parameters to set the private member variables EmployeePerson::EmployeePerson(string empFullName, string empDepartmentCode, string empBirthday, int empAnnualSalary) { SetData(empFullName, empDepartmentCode, empBirthday, empAnnualSalary); } // *********************************************************************** void EmployeePerson::SetData(string empFullName, string empDepartmentCode, string empBirthday, int empAnnualSalary) { fullName = empFullName; departmentCode = empDepartmentCode; birthday = empBirthday; annualSalary = empAnnualSalary; } // *********************************************************************** void EmployeePerson::PrintInfo() { cout << "Name: " << fullName << ", Department: " << departmentCode << ", Birthday: " << birthday << ", Salary: " << annualSalary; } Employee Manager.h #ifndef EMPLOYEEMANAGER_H #define EMPLOYEEMANAGER_H #include #include #include "EmployeePerson.h" using namespace std; class EmployeeManager : public EmployeePerson { public: EmployeeManager(); EmployeeManager(int nManaged); int GetNumManaged(); void PrintInfo(); private: int numManaged; }; #endif

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

SQL Antipatterns Avoiding The Pitfalls Of Database Programming

Authors: Bill Karwin

1st Edition

1680508989, 978-1680508987

More Books

Students also viewed these Databases questions

Question

2. Define identity.

Answered: 1 week ago

Question

1. Identify three communication approaches to identity.

Answered: 1 week ago

Question

4. Describe phases of majority identity development.

Answered: 1 week ago