Question
PLease do this quickly within 30mins please emergency Consider the following UML diagram and do the code in JAVA: Employee class: Employee is an abstract
PLease do this quickly within 30mins please emergency Consider the following UML diagram and do the code in JAVA:
Employee class:
- Employee is an abstract class. [5]
- It has 5 private attributes. [5]
- It has a public constructor, getters and setter methods for all attributes. [5]
- It has two abstract methods: computeWage() and toString(). [10]
- It implements the Comparable interface. The compareTo() method returns -1, 0 or 1 depending on the computed wage of the Employee instances. It does not matter if the objects are of different types (e.g. You are allowed to compare PartTimeEmployee with FullTimeEmployee). [10]
- The class can throw two exceptions: [10]
- InvalidNameException: If the fullName attribute is less than 8 characters in length or null.
- InvalidAgeException: If the age attribute is less than 20.
FullTimeEmployee class:
- computeWage() computes the wage based on the following formula: [5]
W = baseSalary + 10% of baseSalary - 5% of (baseSalary / 2)
PartTimeEmployee class:
- computeWage() computes the wage based on the following formula: [5]
W = (baseSalary / 2) 10% of (baseSalary / 2)
Department class:
- It has two private attributes. [5]
- It has a getter and a setter method for the supervisor attribute. [5]
You are free to choose the format of the String toString() method returns in all three classes. However, make sure to print all the relevant information of the classes. [5]
Driver class:
- Create two FullTimeEmployee objects. Use random data. No need to use Scanner class. [2.5]
- Create two Department objects with names Finance and Public Relations. Assign the previous two Employee objects as supervisors to these Department objects. No need to use Scanner
class. [2.5]
- Create an array of 3 PartTimeEmployee objects. Use random, different data for each object. You do not need to use Scanner class in this task. Use the previously created Department objects as departments for these three objects. [5]
- Invoke toString() methods on all PartTimeEmployee objects by iterating over the array. Print the result. [10]
- Invoke compareTo() method on any two PartTimeEmployee objects. Print the result of the
comparison as well as the computed wage. [10]
Bonus [10]
Introduce a second constructor in the Employee class with the following signature:
public Employee(String fullName, byte age, Department department, double baseSalary )
Inside this constructor, generate a random String which you will use as the value of the id attribute. The String must be generated randomly and may contain A-Z, a-z, 0-9 and underscores( _ ).
vinterface ComparableStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored 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