CS 1410 Programming Lab #10
Templates and Polymorphism with Virtual Functions
Assignment
Modify the code from Lab #9, making Employee into an abstract class and adding a virtual
function to SalesEmployee, SalariedEmployee, and WagedEmployee. Modify the Lab #9 driver
program to place employee objects into a circularly linked list as demonstrated in class.
1. Modify the CList class to make it a “templatized” class
a.
Copy the code from CList.cpp into Clist.h (between the class declaration and the
closing #endif)
b.
Add “template <class T>” before the class and before each member function
c.
Modify all function signatures to reflect the templatized class scope: CList<T>::
d.
Replace Employee with T 2. Modify the Lab #9 driver to place the instantiated employee objects into an instance of
CList
a.
Include the CList header file
b.
Instantiate a circularly linked list
c.
Insert each new employee object (e.g., we and se) in the list
d.
Discard the cout statements at the end of cases 1, 2, and 3
e.
Implement case 4, which calls the CList list function 3. Employee class
a.
Make the Employee class abstract by adding a pure virtual function named
calcPay:
virtual double calcPay() = 0;
b.
Add a “getName” function to return the employee’s name (this is an accessor or
getter function)
c.
Add a virtual display function to display (to cout) the employee’s name,
address, and birth date 4. WagedEmployee class
a.
Add a virtual function named calcPay: double calcPay() to calculate and
return a waged employee’s pay
i.
A waged employee’s pay is his/her wage times the hours worked
b.
Add a virtual display function that
i.
Calls the Employee display function
ii.
Displays the employee’s wage, hours, and pay (i.e., calls calcPay) Page 1 of 2 5. SalariedEmployee class
a.
Add a virtual function named calcPay: double calcPay()
i.
A salaried employee’s pay is his/her salary divided by 24
b.
Add a virtual display function that
i.
Calls the Employee display function
ii.
Displays the employee’s salary and pay (i.e., calls calcPay) 6. SalesEmployee class
a.
Add a virtual function named calcPay: double calcPay()
i.
A sales employee’s pay is his/her salary (call the salaried employee’s
calcPay function) plus commission times sales
b.
Add a virtual display function that
i.
Calls the salaried employee’s display function
ii.
Displays the employees commission, total sales, and pay (i.e., calls
calcPay) Grading
Upload eight files (Driver.cpp, Employee.h, SalariedEmployee.h, WagedEmployee.h,
SalesEmployee.h, Address.h, Date.h, and CList.h) to Canvas for grading Page 2 of 2
Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.
You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.
Read moreEach paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.
Read moreThanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.
Read moreYour email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.
Read moreBy sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.
Read more