@@ -61,7 +61,7 @@ private void printRatingsList(ArrayList<Rating> averageRatings) {
6161 /**
6262 * Print a list of movies and their average ratings sorted by Year and minimal number of raters
6363 *
64- * @param minimalRatings int minimal number of ratings
64+ * @param minimalRatings Minimal number of ratings
6565 * @param year int Year of produce
6666 */
6767 public void printAverageRatingsByYear (int minimalRatings , int year ) {
@@ -76,11 +76,12 @@ public void printAverageRatingsByYear(int minimalRatings, int year) {
7676 /**
7777 * Print a list of movies and their average ratings sorted by Genre
7878 *
79- * @param genre String Genre
79+ * @param minimalRatings Minimal number of ratings
80+ * @param genre Genre
8081 */
81- public void printAverageRatingsByGenre (String genre ) {
82+ public void printAverageRatingsByGenre (int minimalRatings , String genre ) {
8283 ArrayList <Rating > averageRatings =
83- thirdRatings .getAverageRatingsByFilter (1 , new GenreFilter (genre ));
84+ thirdRatings .getAverageRatingsByFilter (minimalRatings , new GenreFilter (genre ));
8485 System .out .printf ("found %d movies%n" , averageRatings .size ());
8586 averageRatings .stream ()
8687 .sorted ()
@@ -94,4 +95,29 @@ public void printAverageRatingsByGenre(String genre) {
9495 MovieDatabase .getGenres (movieID ));
9596 });
9697 }
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+ }
97123}
0 commit comments