@@ -46,16 +46,20 @@ public void printAverageRatings(int minimalRatings) {
46
46
printRatingsList (averageRatings );
47
47
}
48
48
49
- private void printRatingsList (ArrayList <Rating > averageRatings ) {
50
- averageRatings .stream ()
49
+ private void printRatingsList (ArrayList <Rating > averageRatingList ) {
50
+ System .out .printf ("Found %d movies%n" , averageRatingList .size ());
51
+ averageRatingList .stream ()
51
52
.sorted ()
52
53
.forEach (
53
- rating ->
54
- System .out .printf (
55
- "%-4s %s %s%n" ,
56
- rating .getValue (),
57
- MovieDatabase .getYear (rating .getItem ()),
58
- MovieDatabase .getTitle (rating .getItem ())));
54
+ rating -> {
55
+ String movieID = rating .getItem ();
56
+ System .out .printf ("%-4s %s%n" , rating .getValue (), MovieDatabase .getTitle (movieID ));
57
+ System .out .println (" Year: " + MovieDatabase .getYear (movieID ));
58
+ System .out .println (" Time: " + MovieDatabase .getMinutes (movieID ));
59
+ System .out .println (" Genre(s): " + MovieDatabase .getGenres (movieID ));
60
+ System .out .println (" Director(s): " + MovieDatabase .getDirector (movieID ));
61
+ });
62
+ System .out .println ("-------" );
59
63
}
60
64
61
65
/**
@@ -65,12 +69,8 @@ private void printRatingsList(ArrayList<Rating> averageRatings) {
65
69
* @param year int Year of produce
66
70
*/
67
71
public void printAverageRatingsByYear (int minimalRatings , int year ) {
68
- System .out .println ("number of raters " + thirdRatings .getRaterSize ());
69
- System .out .println ("number of movies " + MovieDatabase .size ());
70
- ArrayList <Rating > aveRating =
71
- thirdRatings .getAverageRatingsByFilter (minimalRatings , new YearAfterFilter (year ));
72
- System .out .printf ("found %d movies%n" , aveRating .size ());
73
- printRatingsList (aveRating );
72
+ printRatingsList (
73
+ thirdRatings .getAverageRatingsByFilter (minimalRatings , new YearAfterFilter (year )));
74
74
}
75
75
76
76
/**
@@ -80,20 +80,8 @@ public void printAverageRatingsByYear(int minimalRatings, int year) {
80
80
* @param genre Genre
81
81
*/
82
82
public void printAverageRatingsByGenre (int minimalRatings , String genre ) {
83
- ArrayList <Rating > averageRatings =
84
- thirdRatings .getAverageRatingsByFilter (minimalRatings , new GenreFilter (genre ));
85
- System .out .printf ("found %d movies%n" , averageRatings .size ());
86
- averageRatings .stream ()
87
- .sorted ()
88
- .forEach (
89
- rating -> {
90
- String movieID = rating .getItem ();
91
- System .out .printf (
92
- "%-4s %s%n %s%n" ,
93
- rating .getValue (),
94
- MovieDatabase .getTitle (movieID ),
95
- MovieDatabase .getGenres (movieID ));
96
- });
83
+ printRatingsList (
84
+ thirdRatings .getAverageRatingsByFilter (minimalRatings , new GenreFilter (genre )));
97
85
}
98
86
99
87
/**
@@ -104,20 +92,19 @@ public void printAverageRatingsByGenre(int minimalRatings, String genre) {
104
92
* @param maxMinutes Maximum length of movies in minutes
105
93
*/
106
94
public void printAverageRatingsByMinutes (int minimalRatings , int minMinutes , int maxMinutes ) {
107
- ArrayList < Rating > averageRatings =
95
+ printRatingsList (
108
96
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
- });
97
+ minimalRatings , new MinutesFilter (minMinutes , maxMinutes )));
98
+ }
99
+
100
+ /**
101
+ * Print a list of movies and their average ratings sorted by time
102
+ *
103
+ * @param minimalRatings Minimal number of ratings
104
+ * @param directors directors of the movies
105
+ */
106
+ public void printAverageRatingsByDirectors (int minimalRatings , String directors ) {
107
+ printRatingsList (
108
+ thirdRatings .getAverageRatingsByFilter (minimalRatings , new DirectorsFilter (directors )));
122
109
}
123
110
}
0 commit comments