Sign in to track progress, unlock prep layers, and browse your pipeline.Sign in
Design a menu manager with enums
Design a Console-Based Restaurant Menu Manager
Implement a console-based restaurant menu management program with the following features:
Core Requirements
- Fixed Categories: There are exactly three predefined item categories (e.g.,
APPETIZER,MAIN,DESSERT), which must be represented using anenum. - CRUD Operations: Support the following operations:
addItem(name, price, category): Adds a new menu item.updatePrice(name, newPrice): Updates the price of an existing item.removeItem(name): Removes an item from the menu.listAll(): Lists all menu items.listByCategory(category): Lists items belonging to a specific category.
- Output Formatting: When listing items, use each item object's
toString()method for representation. Output must be grouped by category, and items within each category must be sorted alphabetically by name. - Performance Constraints: Choose appropriate data structures to achieve:
- O(1) time complexity for
addItem,updatePrice, andremoveItemoperations (by item name). - O(k log k) time complexity for
listByCategory(wherekis the number of items in that category).
- O(1) time complexity for
- User Interface & Testing: Provide a simple command-line interface (CLI) that reads commands from standard input and executes them. Include basic unit tests for the core menu management logic.
AI interview prep
Core dilemma
Balancing the need for O(1) constant-time CRUD operations by item name with the requirement for O(k log k) sorted retrieval of items grouped by category, all while managing a fixed set of categories and specific output formatting.
Mid-level signals3
Senior signals3
Red flags4
2 tradeoffs and 2 stress tests locked
Interview prep
Unlock the interviewer X-Ray rubric, tradeoff matrix, stress tests, clarifying questions, and key concepts.
Design a menu manager with enums
Design a Console-Based Restaurant Menu Manager
Implement a console-based restaurant menu management program with the following features:
Core Requirements
- Fixed Categories: There are exactly three predefined item categories (e.g.,
APPETIZER,MAIN,DESSERT), which must be represented using anenum. - CRUD Operations: Support the following operations:
addItem(name, price, category): Adds a new menu item.updatePrice(name, newPrice): Updates the price of an existing item.removeItem(name): Removes an item from the menu.listAll(): Lists all menu items.listByCategory(category): Lists items belonging to a specific category.
- Output Formatting: When listing items, use each item object's
toString()method for representation. Output must be grouped by category, and items within each category must be sorted alphabetically by name. - Performance Constraints: Choose appropriate data structures to achieve:
- O(1) time complexity for
addItem,updatePrice, andremoveItemoperations (by item name). - O(k log k) time complexity for
listByCategory(wherekis the number of items in that category).
- O(1) time complexity for
- User Interface & Testing: Provide a simple command-line interface (CLI) that reads commands from standard input and executes them. Include basic unit tests for the core menu management logic.