In this lab, you are going to use the dynamic binding feature in C++ to construct a management system in an IT Corporation. The source files are available HERE.
Although the outbreak of Covid-19 has an impact on the whole society, your corporation is thriving well, thanks to the strong technology. In order to manage the employees in the corporation, the CEO decides to build a management system to manage his employees more efficiently. Now, this task is assigned to you.
Here are some salary guidelines in the corporation:
There are 4 classes involved: Employee, Manager, Technician,
TechnicianLeader.
The relationships between them are shown in the following figures. Detailed descriptions for each class can also be found below.
Note: '+': public; '-': private; '#': protected
This class is the abstract base class of Manager, Technician,
TechnicianLeader. This class contains the information of an employee including
the id, name, gender, entry date, post and the salary.
It has two constructors: Employee() and Employee(int id, const
string& name, char gender,
const Date& entry_date, string post, Department dept). The former does nothing, while the latter will
set all the properties of the employee.
The destructor ~Employee() should print:
Resign: Empolyee namewhere name is the employee's name.
get_name() will return the name of the employee.
print_salary() should print:
name : $salarywhere name and salary are the properties of the employee.
calculate_salary() will calculate and set the
salary of the employee based on his duty. This function is a pure virtual function.
print_description() should print the information of the employee.
This function is a pure virtual function.
This class is derived from Employee. It contains two private members.
staffs is an array of employees supervised by this manager.
MAX_STAFF_NUM is defined to limit the maximum number of the staffs.
num_staff is the number of employees in the staffs array.
It has two constructors: Manager() and Manager(int id, const string&
name, char gender,
const Date& entry_date, Department dept). The former does nothing, while the latter will
set all the properties of the manager, set post to "Manager", and allocate memory for the staffs based on
MAX_STAFF_NUM.
The destructor ~Manager() should first delete the staffs array. As we claim that an employee (except the manager itself) must have a manager, remember
to also delete each pointed employee before deleting the array. After that, print:
Resign: Manager namewhere name is the manager's name.
manage(Technician *t) will append the technician to the staff array.
The num_staff should be increased by one. When a staff is appended, it should print:
name_s is managed by name_m now!where name_s is the name of the staff and name_m is the name of the manager. (For simplicity, you do not need to check whether the
staffs is out of bound. We assume that a
manager will always manage at most MAX_STAFF_NUM employees.)
calculate_salary() will calculate the salary of the manager by
the formula: 20000 + 2000 * num_staff,
and then set the salary of the class.
print_description() should print:
ID: id, Name: name, Gender: gender, Entry date: entry_date, Post: Manager, Group: deptwhere id, name, gender, and dept are properties of the manager, and entry_date should be represented as "yyyy-mm-dd". Note that to print the string of
dept, please use the
enum_to_str(Department dept) in the
Employee.cpp.
print_staff() should print:
name_m is managing num_staff staffs: [name_1, ][name_2, ]...[name_x, ]where name_m is the name of the manager, num_staff is the property of the manager, and name_x is the name of the x-th staff.
This class is derived from Employee. It contains a protected member:
num_projects, which indicates the number of projects he works on this month.
It has two constructors: Technician() and Technician(int id, const
string& name, char gender,
const Date& entry_date, int num_projects, Department dept). The former does nothing,
while the latter will
set all the properties of the technician, and set post to "Technician".
The destructor ~Technician() should print:
Resign: Technician namewhere name is the technician's name.
calculate_salary() will calculate and set the salary of the Technician by
the formula: 10000 + 1000 * num_projects, where num_projects is the property,
and then set the salary of the class.
print_description() should print:
ID: id, Name: name, Gender: gender, Entry date: entry_date, Post: Technician, Group: dept, Finished num_projects: num_projectswhere id, name, gender, dept and num_projects are properties of the Technician, and entry_date should be represented as "yyyy-mm-dd" based on the property. Note that to print the string of
dept, please use the
enum_to_str(Department dept) in the
Employee.cpp.
This class is derived from Technician.
It has two constructors: TechnicianLeader() and TechnicianLeader(int
id, const string& name, char gender,
const Date& entry_date, int num_projects, Department dept). The former does nothing,
while the latter will
set all the properties of the technicianLeader, and set post to "Technician Leader".
The destructor ~TechnicianLeader() should print:
Resign: TechnicianLeader namewhere name is the TechnicianLeader's name.
calculate_salary() will calculate and set the salary of the TechnicianLeader by
the formula: 20000 + 1500 * num_projects.
print_description() should print:
ID: id, Name: name, Gender: gender, Entry date: entry_date, Post: Technician Leader, Group: dept, Finished num_projects: num_projectswhere id, name, gender, dept and num_projects are properties of the TechnicianLeader, and entry_date should be represented as "yyyy-mm-dd". Note that to print the string of
dept, please use the
enum_to_str(Department dept) in the
Employee.cpp.
.h files, Employee.cpp and main.cpp are given to you.
Please read the description and these files to understand the relationship. Noted that calculate_salary()
and print_description() are pure virtual functions.
Manager.cpp, Technician.cpp,
and TechnicianLeader.cpp.
ID: 101, Name: Bruce Wayne, Gender: M, Entry date: 2016-5-10, Post: Manager, Group: HumanResource
ID: 102, Name: Peter Parker, Gender: F, Entry date: 2020-6-10, Post: Technician, Group: Game, Finished num_projects: 4
Peter Parker is managed by Bruce Wayne now!
ID: 103, Name: Tony Stark, Gender: M, Entry date: 2018-7-10, Post: Technician Leader, Group: FrontEnd, Finished num_projects: 2
Tony Stark is managed by Bruce Wayne now!
ID: 104, Name: Steve Rogers, Gender: F, Entry date: 2021-11-11, Post: Technician, Group: Backend, Finished num_projects: 1
Steve Rogers is managed by Bruce Wayne now!
ID: 105, Name: Bruce Banner, Gender: M, Entry date: 2019-12-3, Post: Technician Leader, Group: Operation, Finished num_projects: 3
Bruce Banner is managed by Bruce Wayne now!
Bruce Wayne is managing 4 staffs: Peter Parker, Tony Stark, Steve Rogers, Bruce Banner,
Bruce Wayne : $28000
Peter Parker : $14000
Tony Stark : $23000
Steve Rogers : $11000
Bruce Banner : $24500
Resign: Technician Peter Parker
Resign: Empolyee Peter Parker
Resign: TechnicianLeader Tony Stark
Resign: Technician Tony Stark
Resign: Empolyee Tony Stark
Resign: Technician Steve Rogers
Resign: Empolyee Steve Rogers
Resign: TechnicianLeader Bruce Banner
Resign: Technician Bruce Banner
Resign: Empolyee Bruce Banner
Resign: Manager Bruce Wayne
Resign: Empolyee Bruce Wayne
- Manager.cpp - Technician.cpp - TechnicianLeader.cppYou can submit your codes multiple times to ZINC before the deadline. Only the last submission will be graded.