Menu Recommendation - OOps
Menu Recommendation - OOps
The average rating of an item is calculated as: (sum of ratings for an item) / (total
number of people who have rated this item).
The driver code takes care of input and calls the relevant functions. There are
totalNumberOfRequests, and each of the next lines is a request that is one of 6 types of
function call.
Constraints
• 1 ≤ totalNumberOfRequests ≤ 105
• 1 ≤ itemId ≤ 105
• 1 ≤ rating ≤ 5
• 1 ≤ |displayName| ≤ 10
Input Format For Custom Testing
The first line contains an integer, totalNumberOfRequests, the number of requests.
Each i of the next totalNumberOfRequests contains a request described above.
Sample Case 0
Sample Input For Custom Testing
8
getRecommendedItem
addItem 1 Item1
rateItem 1 5
getRecommendedItem
outOfStockItem 1
rateItem 1 4
rateItem 1 4
getRecommendedItem
Sample Output
N/A
1 Item1 Rating: 5.0
N/A
Explanation
• getRecommendedItem - there are no item entries so this outputs 'N/A'
• addItem 1 Item1 - Adds Item1 with itemId 1.
• rateItem 1 5 - Adds a rating of 5 to Item1.
• getRecommendedItem - there is only 1 item added yet with 1 rating of 5.
• outOfStockItem 1 - marks Item1 as out of stock
• rateItem 1 4 - Adds a rating of 4 to Item1.
• rateItem 1 4 - Adds a rating of 4 to Item1.
• getRecommendedItem - There are no items in stock to recommend.