Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

Add the following methods to the class RatingRegister: public void addRating(Person person, Film film, Rating rating) adds the rating of a specific film to the

Add the following methods to the class RatingRegister: public void addRating(Person person, Film film, Rating rating) adds the rating of a specific film to the parameter person. The same person can recommend a specific film only once. The person rating has also to be added to the ratings connected to all the films. public Rating getRating(Person person, Film film) returns the rating the parameter person has assigned to the parameter film. If the person hasn't evaluated such film, the method returns Rating.NOT_WATCHED. public Map getPersonalRatings(Person person) returns a HashMap which contains the person's ratings. The HashMap keys are the evaluated films, and their values are the ratings of these films. public List reviewers() returns a list of the people who have evaluated the films. People's ratings should be stored into a HashMap, and the people should act as keys. The values of the HashMap is another HashMap, whose keys are films and whose values are ratings. Test your improved RatingRegister with the following source code:

image text in transcribed

RatingRegister ratings = new RatingRegister(); Film goneWithTheWind = new Film("Gone with the Wind"); Film eraserhead = new Film("Eraserhead"); Person matti = new Person("Matti"); Person pekka = new Person ("Pekka"); ratings.addRating(matti, goneWithTheWind, Rating. BAD); ratings.addRating(matti, eraserhead, Rating .FINE); ratings.addRating (pekka, goneWithTheWind, Rating. GOOD); ratings.addRating(pekka, eraserhead, Rating. GOOD); System.out.println("Ratings for Eraserhead: " + ratings.getRatings (eraserhead)); System.out.println("Matti's ratings: " + ratings.getPersonalRatings(matti)); System.out.println("Reviewers: " + ratings.reviewers()); Ratings for Eraserhead: [FINE, GOOD] Matti's ratings: {Gone with the Wind=BAD, Eraserhead=FINE} Reviewers: [Pekka, Mattil RatingRegister ratings = new RatingRegister(); Film goneWithTheWind = new Film("Gone with the Wind"); Film eraserhead = new Film("Eraserhead"); Person matti = new Person("Matti"); Person pekka = new Person ("Pekka"); ratings.addRating(matti, goneWithTheWind, Rating. BAD); ratings.addRating(matti, eraserhead, Rating .FINE); ratings.addRating (pekka, goneWithTheWind, Rating. GOOD); ratings.addRating(pekka, eraserhead, Rating. GOOD); System.out.println("Ratings for Eraserhead: " + ratings.getRatings (eraserhead)); System.out.println("Matti's ratings: " + ratings.getPersonalRatings(matti)); System.out.println("Reviewers: " + ratings.reviewers()); Ratings for Eraserhead: [FINE, GOOD] Matti's ratings: {Gone with the Wind=BAD, Eraserhead=FINE} Reviewers: [Pekka, Mattil

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_2

Step: 3

blur-text-image_3

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

Database Machine Performance Modeling Methodologies And Evaluation Strategies Lncs 257

Authors: Francesca Cesarini ,Silvio Salza

1st Edition

3540179429, 978-3540179429

More Books

Students explore these related Databases questions