Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.
image text in transcribed

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

Oracle 10g Database Administrator Implementation And Administration

Authors: Gavin Powell, Carol McCullough Dieter

2nd Edition

1418836656, 9781418836658

More Books