The objective of the lab is to take the UML Class diagram and enhance last week\
ID: 3644742 • Letter: T
Question
The objective of the lab is to take the UML Class diagram and enhance last week's Employee class by making the following changes:
Deliverables
Due this week:
Capture the Console output window and paste into a Word Document.
Zip the project folder.
Put the zip file and screenshots (word document) in the drop box.
i L A B S T E P S
STEP 1: Understand the UML Diagram
Analyze and understand the object UML diagram, which models the structure of the program.
There are two new Employee derived classes (1) Salaried and (2) Hourly that are derived from the Employee class.
The Employee class contains a new attribute employeeType and a new constructor that accepts as an argument the assigned employee type.
Both the Salaried and the Hourly classes override only the CalculateWeeklyPay method of the Employee class (note, this is the method without any parameters.)
The Salaried class has one attribute "managementLevel" that has possible values from MIN_MANAGEMENT_LEVEL to MAX_MANAGEMENT_LEVEL and a BONUS_PERCENT.
The Salaried class has a default constructor and parameterized constructor that accepts all the general employee information plus the management level.
The Hourly has a wage attribute, which respresents the hourly wage that ranges from MIN_WAGE to MAX_WAGE, a hours attributes, which represents the number of hours worked in a week that ranges from MIN_HOURS to MAX_Hours, and a category attributes that accepts string values.
The Hourly class has a default constructor and parameterized constructor that accepts all the general employee information plus the hours and wage value.
The Presentation Tier contains two new classes (1) The EmployeeInput class and the EmployeeOutput class
The EmployeeInput class contains three static methods (1) CollectEmployeeInformation, which accepts any type of Employee object as a argument; (2) CollectHourlyInformation, which accepts only Hourly objects as an argument, and (3) CollectSalariedInformation, which accepts only Salaried objects as an argument.
The EmployeeOutput class contains two methods (1) DisplayEmployeeInformation, which accepts any Employee type as an argument and (2) DisplayNumberObjects method.
All the access specifers for the Employee attributes are changed to protected and are depicted with the "#" symbol.
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 previous weeks labs to create the project and the folders.
Note: as an alternative you can open up the Week 4 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 4 project is error free.
STEP 3: Modify the Employee Class
STEP 4: Create the Salaried Class
STEP 5: Create the Hourly Class
STEP 6: Create the EmployeeInput Class
STEP 7: Create the EmployeeOutputClass
[Hint: move the the statements from the main program into these methods.]
STEP 8: Create the Main Program
Use the following if statement to determine the specific type of object:
if (employeeList[i] is Hourly)
EmployeeInput.CollectHourlyInformation((Hourly)employeeList[i]);
else if (employeeList[i] is Salaried)
EmployeeInput.CollectSalariedInformation((Salaried)employeeList[i]);
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:
Deliverables
Explanation / Answer
class MyBase { private int x; public MyBase(int x) { this.x = x; } public int getX() { return x; } public void show() { System.out.println("x=" + x); } } class MyDerived extends MyBase { private int y; public MyDerived(int x) { super(x); } public MyDerived(int x, int y) { super(x); this.y = y; } public int getY() { return y; } public void show() { System.out.println("x = " + getX()); System.out.println("y = " + y); } } public class Inheritance1 { public static void main(String[] args) { MyBase b = new MyBase(2); b.show(); MyDerived d = new MyDerived(3, 4); d.show(); } } class MyDerived extends MyBase { int y; public MyDerived(int x) { super(x); } public MyDerived(int x, int y) { super(x); this.y = y; } public int getY() { return y; } public void show() { super.show(); System.out.println("y = " + y); } } class Purple { protected int i = 0; public Purple() { System.out.println("Purple() running and i = " + i); } public Purple(int i) { this.i = i; System.out.println("Purple(i) running and i = " + i); } } class Violet extends Purple { Violet() { System.out.println("Violet(i) running and i = " + i); } Violet(int i) { System.out.println("Violet(i) running and i = " + i); } } public class Inheritance2 { public static void main(String[] args) { new Violet(); new Violet(4); } } package employees; public abstract class Person { private String firstName; private String lastName; public Person() { } public Person(String firstName, String lastName) { setFirstName(firstName); setLastName(lastName); } public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } public String getFullName() { return firstName + " " + lastName; } }
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.