Purpose To review interfaces Directions Your task for this lab is to implement and test a class to store ratings of items. Your Rating class should have the following fields and methods: private double sumofRatings - the sum of all of the ratings private int raters - the number of people who have rated an item public Rating () - initialize both fields to zero public Rating (double sumofRatings, int raters) - initialize the fields to the parameter values public void addRating (double newRating) - increase the sumofRatings by newRating and increase the number of raters by one public double getAverageRating () - return the average rating; if there are no raters so far, return 0.0 public String tostring () reviews it is based on; for example, if the sum of the ratings is 32 and that is based on ratings from ten people, the toString method will display the average rating and how many return "3.2 based on 10 reviews" Your Rating class should also implement the Comparable interface - Ratings should be sorted such that the highest average rating appears first. If two Rating objects have the same average, the one with the higher number of reviews should appear first.
Purpose To review interfaces Directions Your task for this lab is to implement and test a class to store ratings of items. Your Rating class should have the following fields and methods: private double sumofRatings - the sum of all of the ratings private int raters - the number of people who have rated an item public Rating () - initialize both fields to zero public Rating (double sumofRatings, int raters) - initialize the fields to the parameter values public void addRating (double newRating) - increase the sumofRatings by newRating and increase the number of raters by one public double getAverageRating () - return the average rating; if there are no raters so far, return 0.0 public String tostring () reviews it is based on; for example, if the sum of the ratings is 32 and that is based on ratings from ten people, the toString method will display the average rating and how many return "3.2 based on 10 reviews" Your Rating class should also implement the Comparable interface - Ratings should be sorted such that the highest average rating appears first. If two Rating objects have the same average, the one with the higher number of reviews should appear first.
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY