Question: 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

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
Get step-by-step solutions from verified subject matter experts
