Question: LW 23.1: Employee inheritance scheme Labwork-- This language is in C++. In this labwork, you will implement a simple class hierarchy for a payroll processing
LW 23.1: Employee inheritance scheme
Labwork-- This language is in C++.
In this labwork, you will implement a simple class hierarchy for a payroll processing program for hourly and salaried employees.
Note: Dont worry about polymorphic types in this labwork as we probably havent covered this topic at the time of assignment of this lab; just worry about straight implementation inheritance from the base to the derived class.
You will implement this by writing four class definitions according to the following inheritance UML diagram.
Recall (or soon recall) the concepts of Inheritance from lecture:
https://drive.google.com/open?id=1uy3Mf9Mojm4m_uxgTPaX2MTTi3olXI65
Your implementation of the payroll processing program will follow these requirements:
An Employee with be the base/parent class
The HourlyEmployee and SalariedEmployee classes are inherited from Employee. (They constitute an is a relationship with Employee, but are then specialized into distinct entities.)
A Manager is a SalariedEmployee which is, in turn, an Employee. A Manager, therefore, has the attributes of SalariedEmployee along with the attributes that SalariedEmployee inherited from Employee. Since Manager declares a weekly_pay function, it will hide that one inherited from SalariedEmployee.
Source and Header Files
Create a source (.cpp) and header (.h) file for each class: Employee, HourlyEmployee, SalariedEmployee, and Manager. Each class should be defined in its own header (.h) file, with all member functions defined in a corresponding source (.cpp) file.
Initialization
The parent class should always be initialized using its constructor, called through the child classs initializer list. Refer to the lecture slides on Inheritance to see how this is done.
The child class constructor will always provide parameters that can be used initialize its private data members, along with those that it can pass to the parents constructor to initialize the parents portion of the object.
For instance, the parameterized constructor for HourlyEmployee could be defined as follows:
HourlyEmployee::HourlyEmployee(std::string name, double hourly_wage) : Employee(name), hourly_wage(hourly_wage) {}
Functions
With the exception of weekly_pay member function, the definitions for the remaining member functions should be intuitive. The calculation weekly_pay member function should be implemented such that:
Salaried employees get paid their salary regardless of how many hours they work
Managers are salaried employees who get paid a bonus in addition to their salary
Hourly employees will be paid an hourly rate, but if they work more than 40 hours, then the excess hours are paid at time and a half.
Driver
Create a driver program to test each of these user-defined types. You should create objects of each type and write code that interacts with them in a manner that shows youve written the required member functions, and that your inheritance scheme is implemented correctly. For instance, can you create a vector
Employee name: std::string + Employee() + Employee(std::string) + set_name(std::string + get name): std::string Hourly Employee SalariedEmployee nual salary: double + SalariedEmployee) + SalariedEmployee( name: std:Sstring, annual salary: double) +weekly-pay (): double hourly-wage : double urs worked: double +HourlyEmployee( ) + HourlyEmployee( name: std::string, hourly_wage: double ) + set hours worked( double ) + get hours worked) : double +weekly-pay (): double Manager weekly-bonus + Manager() + Manager(name : std:string, annual salary : double double, weekly_bonus : double) +weekly-pay (): double Employee name: std::string + Employee() + Employee(std::string) + set_name(std::string + get name): std::string Hourly Employee SalariedEmployee nual salary: double + SalariedEmployee) + SalariedEmployee( name: std:Sstring, annual salary: double) +weekly-pay (): double hourly-wage : double urs worked: double +HourlyEmployee( ) + HourlyEmployee( name: std::string, hourly_wage: double ) + set hours worked( double ) + get hours worked) : double +weekly-pay (): double Manager weekly-bonus + Manager() + Manager(name : std:string, annual salary : double double, weekly_bonus : double) +weekly-pay (): double
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
