0% found this document useful (0 votes)
24 views2 pages

Menu Recommendation - OOps

The document outlines the design of a menu recommendation system for a restaurant, detailing the logic for recommending items based on availability and ratings. It specifies the implementation of a class MenuRecommendation that includes methods for adding items, recommending items, marking items as out of stock, restocking, and rating items. Additionally, it provides constraints and input format for testing the system with a sample case demonstrating the functionality of the methods.

Uploaded by

Techno VSP
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views2 pages

Menu Recommendation - OOps

The document outlines the design of a menu recommendation system for a restaurant, detailing the logic for recommending items based on availability and ratings. It specifies the implementation of a class MenuRecommendation that includes methods for adding items, recommending items, marking items as out of stock, restocking, and rating items. Additionally, it provides constraints and input format for testing the system with a sample case demonstrating the functionality of the methods.

Uploaded by

Techno VSP
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Menu Recommendation

Design a menu recommendation system for a restaurant. It suggests an item that


one might want to try from a restaurant.

The recommendation is made using the following logic:


• If the head chef decides to offer a dish as "the deal of the day", it is recommended.
• If there is no "deal of the day" item, the item with the highest average rating is recommended.
• If there is a "deal of the day" item, but it is out of stock, the in-stock item with the highest
average rating is recommended.

The average rating of an item is calculated as: (sum of ratings for an item) / (total
number of people who have rated this item).

Complete the class MenuRecommendation that implements the interface


IMenuRecommendation:
• void addItem(int itemId, String displayName): Create and store a MenuItem object from the
given information. The definition of class MenuItem is given in the code stub.
• MenuItem getRecommendedItem(): Return the recommended MenuItem. If there is no
such MenuItem, return null.
• void outOfStockItem(int itemId): Mark itemId as out of stock.
• void restockItem(int itemId): Mark itemId as back in stock.
• void makeDealOfTheDayItem(int itemId): Mark itemId as the deal of the day and the
recommended item.
• void rateItem(int itemId, int rating): A user rated the item with itemId as rating number of
points.

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.

You might also like