Question: Suppose that a class BookData has been defined that keeps track of information for a book and how it is rated by customers ( real

Suppose that a class BookData has been defined that keeps track of information for a book and how it is rated by customers (real
numbers between 0.0 and 5.0). The class code is linked under the problem title in "Related Links". The class includes the following
public methods:
Below is an example for a book that has been reviewed four times:
BookData book = new BookData("1984", "George Orwell");
book. review(4.7);
book. review(5);
book. review (4.9);
book. review(4.9);
After these calls, the call book.getRating() would return 4.875(the average of the ratings).
Your task is to modify the class to be Comparable by adding an appropriate compareTo method. Books that have a higher average
rating should be considered "less" than other books so that they appear at the beginning of a sorted list. You should use the complete
value of the average rating rather than the truncated value displayed by toString. Books that have the same average rating should be
ordered by the number of reviews, with books that have been reviewed more often considered "less" than books that have been
reviewed less frequently.
 Suppose that a class BookData has been defined that keeps track

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!