Question: /JavaCS2/src/comparables/Person.java /JavaCS2/src/comparables/Student.java /JavaCS2/src/comparables/Employee.java #2 Recall that the Person class implements the comparable interface public clase Person implements Comparable Now suppose that we want to compare
/JavaCS2/src/comparables/Person.java /JavaCS2/src/comparables/Student.java /JavaCS2/src/comparables/Employee.java

#2

Recall that the Person class implements the comparable interface public clase Person implements Comparable Now suppose that we want to compare employees by their salary. Since Employee extends Person, Employee already implements Comparable, via the Person compareTo method, which compares Person objects by age. Now we want to override that compareTo method in the Employee class in order to make the salary comparisons. For this assignment, modify the tmployee class by implementing a new compareTo method for that cass. Enter the appropriate code in the space provided below, so that employee A is considered less than employee B if the salary of employee A is less than the salary of employee B. Aso, if the salary of employee A is equal to that of employee B, then they should be equal. Remember that the code you enter is located in the Employee dass Compares this object with the specified object for order. @param o the Object to be compared. public int compareTo (Object obj)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
