File tree Expand file tree Collapse file tree 4 files changed +30
-2
lines changed
Expand file tree Collapse file tree 4 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,16 @@ public ArrayList<Rater> getRaterArrayList() {
2424 }
2525
2626 private ArrayList <Movie > movieArrayList ;
27+
28+ /**
29+ * This method returns number of unique Raters
30+ *
31+ * @return int number of unique raters
32+ */
33+ public int getRatersNumber () {
34+ return ratersWithIds .size ();
35+ }
36+
2737 private ArrayList <Rater > raterArrayList ;
2838
2939 private HashMap <String , HashSet <String >> directorsAndItsMovies ;
Original file line number Diff line number Diff line change 1+ public class MovieRunnerAverage {
2+
3+ public MovieRunnerAverage () {}
4+
5+ public void printAverageRatings () {
6+ SecondRatings secondRatings = new SecondRatings ("ratedmovies_short.csv" , "ratings_short.csv" );
7+ System .out .printf (
8+ "Total number of movies %d, total number of raters %d" ,
9+ secondRatings .getMovieSize (), secondRatings .getRaterSize ());
10+ }
11+ }
Original file line number Diff line number Diff line change 1010public class SecondRatings {
1111 private final ArrayList <Movie > myMovies ;
1212 private final ArrayList <Rater > myRaters ;
13+ private final FirstRatings firstRatings ;
1314
1415 public SecondRatings () {
1516 // default constructor
@@ -20,7 +21,7 @@ public SecondRatings() {
2021 // loadRaters methods in FirstRatings to read in all the movie and ratings data and store them
2122 // in the two private ArrayList variables of the SecondRatings class, myMovies and myRaters.
2223 public SecondRatings (String moviesFileName , String ratingsFileName ) {
23- FirstRatings firstRatings = new FirstRatings (moviesFileName , ratingsFileName );
24+ firstRatings = new FirstRatings (moviesFileName , ratingsFileName );
2425 myMovies = firstRatings .getMovieArrayList ();
2526 myRaters = firstRatings .getRaterArrayList ();
2627 }
@@ -42,6 +43,6 @@ public int getMovieSize() {
4243 * @return int number of movies
4344 */
4445 public int getRaterSize () {
45- return this .myRaters . size ();
46+ return this .firstRatings . getRatersNumber ();
4647 }
4748}
Original file line number Diff line number Diff line change 1+ public class Week2 {
2+ public static void main (String [] args ) {
3+ MovieRunnerAverage average = new MovieRunnerAverage ();
4+ average .printAverageRatings ();
5+ }
6+ }
You can’t perform that action at this time.
0 commit comments