Question: Write a Java application which implements the classes outlined in the diagram. The Book class should implement the Comparable interface allowing a collection to be

Write a Java application which implements the classes outlined in the diagram. The Book class should implement the Comparable interface allowing a collection to be sorted using book titles. [10 Marks] b) i. Write a tester class which creates two Publisher objects, maintains a collection of Books in a ArrayList and populates the list with an instance of Fiction and an instance of Non-Fiction. [5 Marks] ii. The tester class should then sort the collection based on book titles using the Collections.sort() method. [2 Marks] iii. The tester class should also allow the sorting of Books by Publisher names through an implementation of the Comparator interface, allowing an instance of the inner class to be passed to the overloaded Collections.sort() method.

Write a Java application which implements the classes outlined in the diagram.

Given the UML diagram outlined below, you are required to: > Book name: String Book() Book(String. Publisher) getName():String getPublisher():Publisher toString():String compareTo(Book):int -publisher 0..1 > Publisher a name: String o address: String Publisher() Publisher(String, String) getName():String getAddress():String toString():String > > Fiction NonFiction of Fiction(String, Publisher) | NonFiction(String Publisher) toString(): String toString():String Write a Java application which implements the classes outlined in the diagram. The Book class should implement the Comparable interface allowing a collection to be sorted using book titles. [10 Marks] b) i. Write a tester class which creates two Publisher objects, maintains a collection of Books in a ArrayList and populates the list with an instance of Fiction and an instance of Non-Fiction. [5 Marks] ii. The tester class should then sort the collection based on book titles using the Collections.sort() method. [2 Marks) iii. The tester class should also allow the sorting of Books by Publisher names through an implementation of the Comparator interface, allowing an instance of the inner class to be passed to the overloaded Collections.sort() method. [8 Marks]

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!