-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMovieRunnerAverage.java
53 lines (47 loc) · 1.77 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
45
46
47
48
49
50
51
52
53
/**
* Write a description of class MovieRunnerAverage here.
*
* @author (your name)
* @version (a version number or a date)
*/
import java.util.*;
public class MovieRunnerAverage
{
public void printAverageRatings(){
// ratings_short.csv
// ratedmovies_short.csv
// ratings.csv
// ratedmoviesfull.csv
// SecondRatings sr = new SecondRatings("ratedmovies_short.csv", "ratings_short.csv");
SecondRatings sr = new SecondRatings();
System.out.println(sr.getMovieSize());
System.out.println(sr.getRaterSize());
ArrayList<Rating> ratedMovieList = sr.getAverageRatings(12);
Collections.sort(ratedMovieList);
int count = 0;
for (Rating rm : ratedMovieList){
String movieTitle = sr.getTitle(rm.getItem());
Double avgRating = rm.getValue();
System.out.println(avgRating + " " + movieTitle);
count ++;
}
System.out.println("Total movies: " + count);
}
public void getAverageRatingsOneMovie(){
//SecondRatings sr = new SecondRatings("ratedmovies_short.csv", "ratings_short.csv");
SecondRatings sr = new SecondRatings();
ArrayList<Rating> avgList = sr.getAverageRatings(3);
// String movieTitle = "The Godfather";
// String movieTitle = "No Country for Old Men";
// String movieTitle = "Inside Llewyn Davis";
String movieTitle = "The Maze Runner";
String movieTitle1 = "Moneyball";
String movieTitle2 = "Vacation";
String id = sr.getId(movieTitle2);
for (Rating r : avgList){
if(r.getItem().equals(id)){
System.out.println(movieTitle2 + " " + r.getValue());
}
}
}
}