Question
Using Java to create the following classes below. Part 1: Create an interface called Employable. It has the following methods: public String getDressCode() public boolean
Using Java to create the following classes below.
Part 1:
Create an interface called Employable.
It has the following methods:
public String getDressCode() public boolean isPaidSalary() public boolean postSecondaryEducationRequired() public String getWorkVerb() default public boolean getsPaid(){ return true; }
Create an abstract class Employee which defines one abstract method: public double getOverTimePayRate(). It also has a String name instance variable. It also implements Employable.
Create the following classes which descend from class Employee; their respective return values for the Employable-interface methods are listed here.
HockeyPlayer (jersey, true, false, play); OVERTIME_PAY_RATE: 0.0 Professor (fancy, true, true, teach); OVERTIME_PAY_RATE: 2.0 Parent(anything, false, false, care); OVERTIME_PAY_RATE: -2.0 GasStationAttendant(uniform, false, false, pump); OVERTIME_PAY_RATE: 1.5
Define the following instance variables for these classes: HockeyPlayer: int numberOfGoals Professor: String teachingMajor Parent: int numberOfHoursSpentPerWeekWithKids GasStationAttendant: double numberOfDollarsStolenPerDay
Create a class called Employees which has an ArrayList of 20 Employee references. The constructor adds five of each type of Employee above, in this order:
HockeyPlayer Wayne Gretzky scored 894 goals HockeyPlayer Who Ever scored 0 goals HockeyPlayer Brent Gretzky scored 1 goal HockeyPlayer Pavel Bure scored 437 goals HockeyPlayer Jason Harrison scored 0 goals
Professor Albert Einstein teaches Physics Professor Jason Harrison teaches Computer Systems Professor Richard Feynman teaches Physics Professor BCIT Instructor teaches Computer Systems Professor Kurt Godel teaches Logic
Parent Tiger Woods spends 1 hour/week with kids Parent Super Mom spends 168 hours/week with kids Parent Lazy Larry spends 20 hours/week with kids Parent Ex Hausted spends 168 hours/week with kids Parent Super Dad spends 167 hours/week with kids
Parent must also @Override getsPaid() to return false.
GasStationAttendant Joe Smith steals 10 dollars a day GasStationAttendant Tony Baloney steals 100 dollars a day GasStationAttendant Benjamin Franklin steals 100 dollars a day GasStationAttendant Mary Fairy steals 101 dollars a day GasStationAttendant Bee See steals 1 dollar a day
Part 2:
The Employee subclasses must override the Object classs equals method, and also must implement the Comparable interface.
To implement the Comparable interface, the following relationships must be defined:
HockeyPlayers with the most goals are considered highest.
Professors who teach Computer Science are considered highest; others are equal.
Parents who spend the most hours/week with their kids are considered highest.
GasStationAttendants who steal the most per week are considered highest.
NOTE: Create separate ArrayLists for each child class!
Use Collections.sort(yourArrayList) to sort each of your four Employees collections. Print them out before and after sorting. The Collections.sort() method automatically uses the compareTo() method you defined.
To override the equals method, each of the four Employee subclasses must implement the following method:
@Override public boolean equals(Object that)
Which returns the following values:
- true, if this == that - false, if that == null - false, if that is not an instanceof the same class (.getClass() != .getClass()) - true for HockeyPlayers if and only if they score the same number of goals - true for Professors if and only if they teach the same subject - true for Parents if and only if they parent the same number of hours - true for GasStationAttendants if and only if they steal the same amount.
The Employees class must contain a method that displays all objects that are equal to one another.
Whenever you override the equals() method you must also override the hashCode() method. Let eclipse do it for you, or do it as follows:
public int hashCode () {
return 0; }
Please follow the instructions above for a good rate
Step 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