Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java Project6: Implement the classes in the following class diagram. The Book class implements the Comparable interface. Use implements Comparable in the class definition. Now,

Java
image text in transcribed
image text in transcribed
Project6: 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 ( Bookl] books) 3. Create another class BookTitleComparator that implements the Comparator interface in which overrides the compare( Book a, Book ) 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) Book MyDate title: String uthor: ArrayList Author publishing: MyDate price: Double MyDate from assignment 4 Bookf title:String, author Author, publiching: MyDate, price: Double) set Titlel title: String): void setAuthorf title: String): void +setDate date: MyDate ): void getDate): MyDate setPricel price: int):void +getPrice (): int +compareTol book: Book): int toStringt):String Author name : String age: int book: ArrayList Book> Authorl name: String, age:int) getName0:String setNamelname String):void eeweak>> BookTitleComparator + getAgeo: String +getBookf title: String) : Book +compare(book1 Book, book2:Book) : int e setBook book: Book ):void toStringo:String Class MyDate should have member of type Date and provide methods and constructor to allow User to create object of myDate

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing

Authors: David J. Auer David M. Kroenke

13th Edition

B01366W6DS, 978-0133058352

More Books

Students also viewed these Databases questions