Description
CIS 247A Week 6 iLab Abstract Classes
Scenario and Summary
The objective of the lab is to take the UML Class diagram and enhance last week’s Employee class by making the following changes:
- Convert the Employee class to an abstract class
- Add an abstract method called CalculateNetPay to the Employee class
- In both the Salaried and Hourly classes implement the CalculateNetPay method
STEP 1: Understand the UML Diagram
Analyse and understand the object UML diagram, which models the structure of the program.
- The Employee class has been specified as abstract, which is denoted by the name of the class being initialized Employee
- The Employee class as a new method CalculateNetPay which is an abstract method, denoted by the italized name of the method. Since this method is an abstract method the CalculateNetPay method WILL NOT have an implementation in the Employee class.
- The Salaried and Hourly classes both have a new method CalculateNetPay that is inherited from the abstract Employee class and the Salaried and Hourly class both MUST implement the CalculateNetPay method.
STEP 2: Create the Project
You will want to use the Week 5 project as the starting point for the lab. Use the directions from the previous weeks labs to create the project and the folders.
- Create a new project named “CIS247_WK6_Lab_LASTNAME”. An empty project will then be created.
- Delete the default Program.cs file that is created.
- Add the Logic Tier, Presentation Tier, and Utilities folders to your project
- Add the Week 5 project files to the appropriates folders.
- Update the program information in the ApplicationUtilities.DisplayApplicationInformation method to reflect your name, current lab, and program description.
Note: as an alternative you can open up the Week 5 project and make modifications to the existing project. Remember, there is a copy of your project in the zip file you submitted for grading.
Before attempting this week’s steps ensure that the Week 5 project is error free.
STEP 3: Modify the Employee Class
- Modify the class declaration of the Employee class to specify that the Employee class is an abstract class
- Declare an abstract method called CalculateNetPay that returns a double value.
- Modify the ToString Method to include the weekly net pay in currency format.
STEP 4: Modify the Salaried Class
- Add a double constant called TAX_RATE and set the value to .73
- Implement the CalculateNetPay method by multiplying the weekly pay by the tax rate.
STEP 5: Modify the Hourly Class
- Add a double constant called TAX_RATE and set the value to .82
- Implement the CalculateNetPay method by multiplying the weekly pay by the tax rate.
STEP 6: Create the Main Program
- Change the employeeList array to only hold two objects.
- Create one Hourly employee object and store it in the array.
- Create one Salaried employee object and store it in the array.
- As you did in the Week 5 lab, prompt for and collect the information for each of the objects.
Note: iterating through the array should not require any changes from the previous iteration of the project–but make sure that the loop stays within the bounds of the array.
STEP 7: 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.
Reviews
There are no reviews yet.