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