Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In my java program they are asking me to use both the compareTo method as well as one other method in order to sort all

In my java program they are asking me to use both the compareTo method as well as one other method in order to sort all the books in a catalog based on their title and I don't know how. This is what is suppose to be written in one of the classes: You will need to write the code for the compareTo method. This method should have one parameter of Book type. The order of the books is based on the alphabetical order of the title. Note that in order to have this method, your Book class should implement the Comparable interface. In addition, in the book catalog class it says : sortByTitle - this method sorts all the books based on title. Finally, in the main class, where I have made a menu for the user to choose what they want to do, for the sort option it says this : For the menu "Sort all the books based on title", you can call Collections.sort method to sort all the books in the list. Make sure you implement compareTo method correctly.

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

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions