@@ -61,7 +61,7 @@ private void printRatingsList(ArrayList<Rating> averageRatings) {
61
61
/**
62
62
* Print a list of movies and their average ratings sorted by Year and minimal number of raters
63
63
*
64
- * @param minimalRatings int minimal number of ratings
64
+ * @param minimalRatings Minimal number of ratings
65
65
* @param year int Year of produce
66
66
*/
67
67
public void printAverageRatingsByYear (int minimalRatings , int year ) {
@@ -76,11 +76,12 @@ public void printAverageRatingsByYear(int minimalRatings, int year) {
76
76
/**
77
77
* Print a list of movies and their average ratings sorted by Genre
78
78
*
79
- * @param genre String Genre
79
+ * @param minimalRatings Minimal number of ratings
80
+ * @param genre Genre
80
81
*/
81
- public void printAverageRatingsByGenre (String genre ) {
82
+ public void printAverageRatingsByGenre (int minimalRatings , String genre ) {
82
83
ArrayList <Rating > averageRatings =
83
- thirdRatings .getAverageRatingsByFilter (1 , new GenreFilter (genre ));
84
+ thirdRatings .getAverageRatingsByFilter (minimalRatings , new GenreFilter (genre ));
84
85
System .out .printf ("found %d movies%n" , averageRatings .size ());
85
86
averageRatings .stream ()
86
87
.sorted ()
@@ -94,4 +95,29 @@ public void printAverageRatingsByGenre(String genre) {
94
95
MovieDatabase .getGenres (movieID ));
95
96
});
96
97
}
98
+
99
+ /**
100
+ * Print a list of movies and their average ratings sorted by time
101
+ *
102
+ * @param minimalRatings Minimal number of ratings
103
+ * @param minMinutes Minimal length of movies in minutes
104
+ * @param maxMinutes Maximum length of movies in minutes
105
+ */
106
+ public void printAverageRatingsByMinutes (int minimalRatings , int minMinutes , int maxMinutes ) {
107
+ ArrayList <Rating > averageRatings =
108
+ thirdRatings .getAverageRatingsByFilter (
109
+ minimalRatings , new MinutesFilter (minMinutes , maxMinutes ));
110
+ System .out .printf ("found %d movies%n" , averageRatings .size ());
111
+ averageRatings .stream ()
112
+ .sorted ()
113
+ .forEach (
114
+ rating -> {
115
+ String movieID = rating .getItem ();
116
+ System .out .printf (
117
+ "%-4s Time: %-3d %s%n" ,
118
+ rating .getValue (),
119
+ MovieDatabase .getMinutes (movieID ),
120
+ MovieDatabase .getTitle (movieID ));
121
+ });
122
+ }
97
123
}
0 commit comments