STEP 1: Understand the UML Diagram Notice the change in UML diagram. It is commo
ID: 3634166 • Letter: S
Question
STEP 1: Understand the UML DiagramNotice the change in UML diagram. It is common practice to leave out the properties or (accessors and mutators - getters and setters) from UML class diagrams, since there can be so many of them. Unless otherwise specified, it is assumed that there is a property or accessor (getter) and a mutator (setter) for every class attribute.
STEP 2: Create the Project
You will want to use the Week 4 project as the starting point for the lab. Use the directions from the iLab Assignment of Week 3 (Step 2) on how to create a new project and copy the files.
Before you move on to the next step, build and execute the Week 5 project.
STEP 3: Modify the Benefits Class
Change the DisplayBenefits method to override the System.Object.ToString method, ensuring that the method returns a string, and does not explicitly display the information, but just returns a string.
STEP 4: Modify the Employee Class
Using the updated Employee class diagram, modify the attributes so that they become protected.
Change the name of the DisplayEmployee method to "ToString", which then overrides the System.Object.ToString() method, and returns a string.
Delete the IEmployee interface, and remove the reference from the Employee class
STEP 5: Create the Salaried Class
Using the UML Diagrams from Step 1, create the Salaried class, ensuring to specify that the Salary class inherits from the Employee class.
For each of the constructors listed in the Salaried class ensure to invoke the appropriate super class constructor and pass the correct arguments to the super class constructor. This will initialize the protected attributes and update the numEmployees counter
The valid management levels are 0, 1, 2, and 3, and should be implemented as a constant.
Override the CalculatePay method to add a 10 percent bonus to the annualSalary depending on the management level. The bonus percent is a fixed 10 percent, and should be implemented as a constant. However, depending on the management level the actual bonus percentage fluctuates (i.e., actualBonusPercentage = managementLevel * BONUS_PERCENT).
Override the ToString method to add the management level to the employee information.
STEP 6: Create the Hourly Class
Using the UML Diagrams from Step 1, create the Hourly classes, ensuring to specify that the Hourly class inherits from the Employee class.
For each of the constructors listed in the Hourly class ensure to invoke the appropriate super class constructor and pass the correct arguments to the super class constructor. This will initialize the protected attributes and update the numEmployees counter.
The valid category types are "temporary", "part time", "full time";
The provided hours must be more than 0 hours and less than 50 hours, and the limits should be implemented as constants.
The provided wage must be between 10 and 75, and the limits should be implemented as constants.
Override the CalculatePay method by multiplying the wages by the number of hours.
Override the ToString method to add the category to the hourly employee information.
If you haven't done so already, make sure you identify the appropriate place(s) in the Hourly class to set the annualSalary attribute to a proper value (call the CalculatePay method to get the weekly pay and multiply the result by 52 in order to calculate and set the annualSalary).
STEP 7: Construct the Main Method
Create an array of type Employee and size 3. Create 3 new objects, one Employee, one Hourly and one Salaried in positions 0, 1 and 2 of the array respectively. Use any constructors you wish except the default.
Using a FOR loop, iterate through the array and call the ToString and CalculatePay methods of each object to display the weekly pay and the employee's information respectively.
Call the GetNumEmployees method to display the total number of employees instantiated.
STEP 8: Compile and Test
When done, compile and run your program.
Then debug any errors until your code is error-free.
Check your output to ensure that you have the desired output and modify your code as necessary and rebuild.
The output of your program should resemble the following:
On-screen output display:
Welcome the Employee Hierarchy Program
CIS247, Week 5 Lab
Name: Solution
This program tests an Employee inheritance hierarchy
*********************** Display Employee's Data **********************
Employee Type
GENERIC
First Name
Joe
Last Name
Doe
Gender
Male
Dependents
1
Annual Salary
$10,000.00
Weekly Pay
$192.31
Health Insurance
Partial
Life Insurance
$1,000.00
Vacation
2
*********************** Display Employee's Data ********************** Employee Type
SALARIED
First Name
Zoe
Last Name
Likoudis
Dependents
3
Management Lv1.
1
Annual Salary
$20,000.00
Weekly Pay
$423.08
Health Insurance
Full
Life Insurance
$2,000.00
Vacation
4
*********************** Display Employee's Data **********************
Employee Type
HOURLY
First Name
Kate
Last Name
Perry
Gender
Female
Dependents
0
Category
part time
Wage
$75.00
Hours
25
Weekly Pay
$1,875.00
Annual Salary
$97,500.00
Health Insurance
Partial
Life Insurance
$3,000.00
Vacation
8
total Number of Employess in Database: 3
Press the ESC key to close the image description and return to lecture
Image Description