Question: JAVA PROGRAMMING Implement the classes in the following class diagram. The Book class implements the Comparable interface. Use implements Comparable in the class definition. Now,

JAVA PROGRAMMING  JAVA PROGRAMMING Implement the classes in the following class diagram. The
Book class implements the Comparable interface. Use implements Comparable in the class

Implement the classes in the following class diagram. The Book class implements the Comparable interface. Use implements Comparable in the class definition. Now, all book objects are instances of the java.lang.Comparable interface. Write a test program that creates an array of ten books. 1. Use Arrays.sort( Book[] books ) from the java.util package to sort the array. The order of objects in the array is determined using compareTo(..) method. 2. Write a method that returns the most expensive book in the array of objects (Books) o The method signature is: public static Book max (Book] books) 3. Create another class BookTitleComparator that implements the Comparator interface in which overrides the compare( Book a, Book b) method. Use the implements Comparator in the class definition in order to compare objects of type Book. The compare(Book a, Book b) method should compare the titles of the two books. 4. Using Arrays.sort( Book[] books, new BookTitleComparator() to sort books by the title. o Arrays.sort( books, new BookTitleComparator() ); 5. Create a method to show each element in the array with the following method signature: o public static void showBooksArray ( books )

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!