@@ -19,8 +19,6 @@ public MovieRunnerWithFilters() {
19
19
* @param minimalRatings int specified number of ratings
20
20
*/
21
21
public void printAverageRatings (int minimalRatings ) {
22
- // ThirdRatings thirdRatings = new ThirdRatings("ratedmovies_short.csv",
23
- // "ratings_short.csv");
24
22
ArrayList <Rating > ratedList = thirdRatings .getAverageRatings (minimalRatings );
25
23
26
24
Collections .sort (ratedList );
@@ -60,6 +58,12 @@ private void printRatingsList(ArrayList<Rating> averageRatings) {
60
58
MovieDatabase .getTitle (rating .getItem ())));
61
59
}
62
60
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
+ */
63
67
public void printAverageRatingsByYear (int minimalRatings , int year ) {
64
68
System .out .println ("number of raters " + thirdRatings .getRaterSize ());
65
69
System .out .println ("number of movies " + MovieDatabase .size ());
@@ -68,4 +72,26 @@ public void printAverageRatingsByYear(int minimalRatings, int year) {
68
72
System .out .printf ("found %d movies%n" , aveRating .size ());
69
73
printRatingsList (aveRating );
70
74
}
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
+ }
71
97
}
0 commit comments