Question
1. Demonstrate polymorphism in C++ If possible try to make each class and its subclasses in separate files while using polymorphism: (Employee.h, SalariedEmployee.h, HourlyEmployee.h, and
1. Demonstrate polymorphism in C++
If possible try to make each class and its subclasses in separate files while using polymorphism: (Employee.h, SalariedEmployee.h, HourlyEmployee.h, and ByPieceEmployee.h)
Also make a main.cpp file
a.Create 1 Employee class and 3 subclasses: SalariedEmployee, HourlyEmployee, and ByPieceEmployee.
b.Employee class has full name and hire date as private data members.
c.Each salaried employee has an annual salary; each hourly employee has wage per hour information; by-piece employees get paid by:
(number of pieces completed) * (rate-perpieces).
d.Create an array of 3 employee pointers, pointers to the base class. The first pointer will point to an object of SalariedEmployee; the second pointer will point to an object of HourlyEmployee and the third pointer will point to a ByPieceEmployee object.
e.Here is the information of these three employees:
f. We assume that this company has a 2 week pay cycle. Test the program with the following data sets, (2 sets).
(For salaried employee, it is 104,000 / 52 * 2 = 4000)
g.Create a virtual function in the base class named CalculatePayAmount(). Also create virtual functions in the three derived classes.
h.For Jose Feliciano, he gets a fixed pay every 2 weeks.
For Madison, the app will need to ask for total hours worked in the 2 weeks.
For Bruce Lee, the app will need to ask for number of pieces he completes within the 2 weeks period.
i.The employee base class should be abstract and the virtual function CalculatePayAmount should be pure.
j. (Required in this program)We need to implementdynamic bindingin this problem, (polymorphism).
NOTE: Show output of 2 runs (using the data sets in part f).
1. Demonstrate polymorphism in C++
If possible try to make each class and its subclasses in separate files while using polymorphism: (Employee.h, SalariedEmployee.h, HourlyEmployee.h, and ByPieceEmployee.h)
Also make a main.cpp file
a.Create 1 Employee class and 3 subclasses: SalariedEmployee, HourlyEmployee, and ByPieceEmployee.
b.Employee class has full name and hire date as private data members.
c.Each salaried employee has an annual salary; each hourly employee has wage per hour information; by-piece employees get paid by:
(number of pieces completed) * (rate-perpieces).
d.Create an array of 3 employee pointers, pointers to the base class. The first pointer will point to an object of SalariedEmployee; the second pointer will point to an object of HourlyEmployee and the third pointer will point to a ByPieceEmployee object.
e.Here is the information of these three employees:
f. We assume that this company has a 2 week pay cycle. Test the program with the following data sets, (2 sets).
(For salaried employee, it is 104,000 / 52 * 2 = 4000)
g.Create a virtual function in the base class named CalculatePayAmount(). Also create virtual functions in the three derived classes.
h.For Jose Feliciano, he gets a fixed pay every 2 weeks.
For Madison, the app will need to ask for total hours worked in the 2 weeks.
For Bruce Lee, the app will need to ask for number of pieces he completes within the 2 weeks period.
i.The employee base class should be abstract and the virtual function CalculatePayAmount should be pure.
j. (Required in this program)We need to implementdynamic bindingin this problem, (polymorphism).
NOTE: Show output of 2 runs (using the data sets in part f).
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started