-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathMovieRunnerAverage.java
44 lines (36 loc) · 1.65 KB
/
MovieRunnerAverage.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/**
* MovieRunnerAverage class contains tests for the getAverageRatings method from the
* secondRatings class.
*
* @ Konstantin Krumin
* @ Version: 1.0 (February 18, 2020)
*/
import java.util.*;
public class MovieRunnerAverage {
public void printAverageRatings () {
SecondRatings secondRatings = new SecondRatings ("ratedmoviesfull", "ratings");
System.out.println("Total number of movies : " + secondRatings.getMovieSize());
System.out.println("Total number of raters : " + secondRatings.getRaterSize());
int MinNumOfRatings = 20; // variable
ArrayList<Rating> averageRatings = secondRatings.getAverageRatings(MinNumOfRatings);
Collections.sort(averageRatings);
for (Rating rating : averageRatings) {
System.out.println(rating.getValue() + " " + secondRatings.getTitle(rating.getItem()));
}
System.out.println("There are " + averageRatings.size() + " movies with " +
MinNumOfRatings + " or more ratings");
}
public void getAverageRatingOneMovie () {
SecondRatings secondRatings = new SecondRatings ("ratedmoviesfull", "ratings");
String title = "Vacation"; // variable
int MinNumOfRatings = 1; // variable
String movieID = secondRatings.getID(title);
ArrayList<Rating> averageRatings = secondRatings.getAverageRatings(MinNumOfRatings);
for (Rating rating : averageRatings) {
if (rating.getItem().equals(movieID)) {
System.out.println("For movie \"" + title + "\" the average rating is "
+ rating.getValue());
}
}
}
}