Question: java question (1) Cons der the Person, Student and Employee that we developed in Lab05 and the Comparable interface from the java.ut package Interface ComparableT>

java question (1)

 java question (1) Cons der the Person, Student and Employee that

Cons der the Person, Student and Employee that we developed in Lab05 and the Comparable interface from the java.ut package Interface ComparableT> int compareTo(T o) You are required to modify the Person cass and implement the comparable interface. You will need to override the compareTo (Person p) method. The compar son is based on the ages. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specfied Person. Write the modified Person class in the answer box below assuming that the student and Employee have been done for you. For example: Test Result Person myListnew Person[2] myList[]new EmployeeC Susan", 43, "Bank tel0], Joe(21)] lers", 68000); myList[1] = new Person("Joe", 21); System.out.println(Arrays.toString(myList)); Employee[Susan(43), Bank tellers, 68808 Person myListnew Person[2]; myList[9]new Employee( Susan", 43, "Bank tels, 68808.08]J lers", 68000); myList[1] = new Person("Joe", 21); Arrays.sort(myList); System.out.println(Arrays.toString(myList)); [Joe(21), Employee Susan(43), Bank teller Answer: (penalty regime:0 %) 1l class Person implements Comparable Person protected String name; protected int age; 5public Person(String name, int age) this.namename; this.age age; 10 public int getAge) return age; 12 13 14 15 16 17 18 19 20 21 public, void setAge(int age) this.age - age; public String getNamet return name; public void setNome(String name) 23 24 25 this . name name public String toString return String.format , nore, age 28 29

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!