Need the final product-- Take the code we\'ve provided for the Employee class (E
ID: 663714 • Letter: N
Question
Need the final product--
Take the code we've provided for the Employee class (Employee.h) and the Manager class (Manager.h).
Add methods to the classes named:
that let users change the corresponding fields. Take advantage of the inheritance relationship between Employee and Manager--you only need to add each of those methods to 1 class.
Write a Supervisor class. A supervisor is responsible for employees in a specific department and must:
Have a field to store the department name (as a string).
Have getDept() and setDept() methods to access the department field.
Always be salaried (i.e., pay for a single pay period is fixed, no matter how many hours are worked).
Have a constructor that takes initial values for all fields.
What class should Supervisor inherit from?
Your code should compile and run correctly with the test program: Empltest.cpp.
---------------------------------------------------------------------------------------------------------------------------------------------------------
employee.h--
---------------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------------
Test program--
---------------------------------------------------------------------------------------------------------------------------------------------------------
A good answer gets 3000 points.
Explanation / Answer
supervisor.cpp
supervisor.h
empltest.cpp
#include <iostream>
#include "employee.cpp"
#include "manager.cpp"
#include "supervisor.cpp"
int main()
{
Employee empl("John Burke", 25.0);
Manager mgr("Jan Kovacs", 1200.0, true);
Supervisor sup("Denise Zephyr", 780.0, "Accounting");
// Assume all employees worked 40 hours this period.
cout << "For Employee:" << endl;
cout << "Name: " << empl.getName() << endl;
cout << "Pay: " << empl.pay(40.0) << endl;
cout << "Changing the Employee's name..." << endl;
empl.setName("Doug Conners");
cout << "New Name: " << empl.getName() << endl;
cout << endl;
cout << "For Manager:" << endl;
cout << "Name: " << mgr.getName() << endl;
cout << "Salaried: " << mgr.getSalaried() << endl;
cout << "Pay: " << mgr.pay(40.0) << endl;
cout << "Changing the Manager's salaried status..." << endl;
mgr.setSalaried(false);
cout << "New Pay: " << mgr.pay(40.0) << endl;
cout << endl;
cout << "For Supervisor:" << endl;
cout << "Name: " << sup.getName() << endl;
cout << "Pay: " << sup.pay(40.0) << endl;
cout << "Dept: " << sup.getDept() << endl;
cout << "Changing the Supervisor's pay rate..." << endl;
sup.setPayRate(900.0);
cout << "New Pay: " << sup.pay(40.0) << endl;
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.