Answered step by step
Verified Expert Solution
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 and 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 "George Orwell"; book. review; book. review; book. review ; book. review; After these calls, the call book.getRating would return 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 of information for a book and how it is rated by customers real
numbers between and 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 "George Orwell";
book. review;
book. review;
book. review ;
book. review;
After these calls, the call book.getRating would return 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.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started