Introduction

Most major websites collect feedback from their customers in order to improve the quality of their services. The most common form of user feedback is ratings. For example, Amazon.com collects users ratings of books (see Figure 1), Imdb.com collects movie ratings and Booking.com gathers users rating of hotels.

Figure 1: Some books ratings on Amazon.com see image.

A rating consists mainly of three important pieces of information:

1. The user ID: this is the ID of the user who gave the rating.

2. The item ID: this is the ID of the item being rated. For example, the item can be a book, a movie or a hotel.

3. The rating value: this is a numerical value that is usually an integer ranging from 1 to 5 (or 1 to 10), where 1 is the lowest rating (user not satisfied) and 5 (or 10) is the highest rating (user very satisfied).

Your goal in this project is to write a program that reads a list of ratings from a text file, stores them efficiently in memory (you should choose the appropriate data structure for this) and answers a number of queries as efficiently as possible. Examples of queries are: What is the rating given by user i to item j? What is the average rating of item j? What is (are) the highest rated item(s)?

Requirements

In this phase, you are required to implement the following classes:

public class Rating { private int userId; private int
itemId; private int value; // The value of the rating
// Constructor public Rating(int userId, int itemId, int
value);
// Getters... (No setters. This class is immutable)
} public class RatingManager {
// Constructor public
RatingManager();
// Read ratings from a file and create a RatingManager object that stores these ratings
public static RatingManager read(String fileName);
// Add a rating public void addRating(Rating
rating);
// Return all ratings given by user i. Search should be efficient. public LinkedList
getUserRatings(int i);
// Return all ratings given to item j. Search should be efficient. public LinkedList
getItemRatings(int j);
// Return the average rating of item j. If i has no ratings, -1 is returned public double
getAverageItemRating(int j);
// Return the average rating given by user i. If i has no ratings, -1 is returned
public double getAverageUserRating(int i);
// Return the list of all items having the highest average rating (for example if the highest average
rating is 4.9, the method should return all items with average rating 4.9)
public LinkedList< Integer> getHighestRatedItems();
}

Let n denote the number of users, m the number of items and k the number of ratings. Usually k is much smaller than nm, because a user does not usually rate all items. Your memory requirement must be O(k) and not O(nm).

Academic Honesty!
It is not our intention to break the school's academic policy. Projects posted are only used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly fill out the form. Please provide a valid email address and we'll get back to you in less than 24 hours. We will be sending an invoice through PayPal upon confirmation. We are a non profit organization however we need an amount to keep this organization running, and to be able to complete our research and development.