Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need help with Week 5 ilab for cis247a i L A B O V E R V I E W Scenario and Summ

ID: 3644949 • Letter: N

Question

Need help with Week 5 ilab for cis247a
i L A B O V E R V I E W
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:
1. Create a derived class called Salaried that is derived from Employee.
2. Create a derived class called Hourly that is derived from Employee.
3. Create generalized input methods that accept any type of Employee or derived Employee object
4. Create generalized output methods that accept any type of Employee or derived Employee object
5. Override the base class CalculatePay method
6. Override one of the base class CalculateWeeklyPay methods
Deliverables

Due this week:

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; } }