MovieRatingsTest.java
public class MovieRatingsTest { public static void main(String args[]) { String[] movies = {"Gravity", "12 Years a Slave", "Spaceballs"}; String[] reviewers = {"Jen", "Bino", "Sophia"}; MovieRatings ratings = new MovieRatings(reviewers, movies); //give some values for the ratings for(int i = 0; i
Create a program to store and process movie ratings. Use a 2D array to store ratings by different reviewers for different movies. Each row represents a different movie and each column represents a different reviewer. There will also be two separate arrays to store the names of movies and the names of the reviewers. You may use the atached t test program MovieRatings ratingsI:int reviewersll String movies]: String +MovieRatings(reviewersI: String, moviesl String) getAvgRating:double +getAvgRatingbyMovie movielndex:int): double + getAvgRatingbyReviewer(reviewerlndex:int):double + getMovielndex(movieName: String):int +getReviewerlndex(reviewerName:String):int +setRating(movielndex:int, reviewerlndex:int, rating:int):void + printMovieRatingsmovielndex:int):void + printReviewerRatings reviewerlndex:int):void MovieRatings() - Constructor for the class One parameter is an array of reviewers names One parameter is an array of movie names Description: set the parameters equal to the private data members for the movies and reviewers, initialize the 2D ratings array based on the size of the reviewers array (rows) and the size of the movies array (columns) . getAvgRating0 Returns a double value representing the average rating Description: Find the average rating for all movies and all reviewers (ie all data in the table) getAvgRatingsbyMovie) One parameter, the index of the movie to find all the reviews for - Returns a double value representing the average rating Description: Find the average rating for a single movie (i e. one column representing all the reviewers scores for that one movie) getAvgRatingsbyReviewer) One parameter, the index of the reviewer to find all the reviews for Returns a double value representing the average rating Description: Find the average rating for a single reviewer (Le-one row representing all the movies for that one reviewer) getMovielndex0 . One parameter, the name of the movie e Returns an integer representing the index number of that movie Description: Searches the movies array to find the index location for that movie. This can then be used to find the ratings for that movie in the ratings 2D array . getReviewerlndex(0 One parameter, the name of the reviewer Returns an integer representing the index number of that reviewer Description: Searches the reviewers array to find the index location for that reviewer This can then be used to find the ratings for that reviewer in the ratings 2D array setRating0 One parameter each for the movie index, for the reviewer index and for the rating to store Description: the reviewer index specifies the row, the movie index specifies the column and the rating is the value to store in that cell printMovieRatings0 One parameter that represents the index of the movie name and the movie ratings a Description: prints the movie name and the ratings to System.out Example: "The Lego Movie: 5, 6, 2,7,8 printReviewerRatings0 One parameter that represents the index of the reviewers name and their movie ratings Description: prints the reviewer name and the ratings to System.out Example: "Roger Ebert: 4, 2, 8, 9