@@ -19,8 +19,6 @@ public MovieRunnerWithFilters() {
1919 * @param minimalRatings int specified number of ratings
2020 */
2121 public void printAverageRatings (int minimalRatings ) {
22- // ThirdRatings thirdRatings = new ThirdRatings("ratedmovies_short.csv",
23- // "ratings_short.csv");
2422 ArrayList <Rating > ratedList = thirdRatings .getAverageRatings (minimalRatings );
2523
2624 Collections .sort (ratedList );
@@ -60,6 +58,12 @@ private void printRatingsList(ArrayList<Rating> averageRatings) {
6058 MovieDatabase .getTitle (rating .getItem ())));
6159 }
6260
61+ /**
62+ * Print a list of movies and their average ratings sorted by Year and minimal number of raters
63+ *
64+ * @param minimalRatings int minimal number of ratings
65+ * @param year int Year of produce
66+ */
6367 public void printAverageRatingsByYear (int minimalRatings , int year ) {
6468 System .out .println ("number of raters " + thirdRatings .getRaterSize ());
6569 System .out .println ("number of movies " + MovieDatabase .size ());
@@ -68,4 +72,26 @@ public void printAverageRatingsByYear(int minimalRatings, int year) {
6872 System .out .printf ("found %d movies%n" , aveRating .size ());
6973 printRatingsList (aveRating );
7074 }
75+
76+ /**
77+ * Print a list of movies and their average ratings sorted by Genre
78+ *
79+ * @param genre String Genre
80+ */
81+ public void printAverageRatingsByGenre (String genre ) {
82+ ArrayList <Rating > averageRatings =
83+ thirdRatings .getAverageRatingsByFilter (1 , new GenreFilter (genre ));
84+ System .out .printf ("found %d movies%n" , averageRatings .size ());
85+ averageRatings .stream ()
86+ .sorted ()
87+ .forEach (
88+ rating -> {
89+ String movieID = rating .getItem ();
90+ System .out .printf (
91+ "%-4s %s%n %s%n" ,
92+ rating .getValue (),
93+ MovieDatabase .getTitle (movieID ),
94+ MovieDatabase .getGenres (movieID ));
95+ });
96+ }
7197}
0 commit comments