Design a menu manager with enums
CloudKitchensSoftware Engineer · Technical ScreenLast updated
This question evaluates data modeling with enums, efficient data structure selection to meet specified time complexities, API design for CRUD operations, and practical implementation skills including a command-line interface and unit testing.
Design and implement a console-based restaurant menu management program. Requirements: (
- There are exactly three fixed item categories represented by an enum (e.g., APPETIZER, MAIN, DESSERT). (
- Support addItem(name, price, category), updatePrice(name, newPrice), removeItem(name), listAll(), and listByCategory(category). (
- Print items using each object's toString() rather than accessing fields via getters; list output grouped by category and sorted alphabetically within each category. (
- Choose data structures to achieve O(
- add/update/remove by name and O(k log k) listing within a category (k = number of items in that category). (
- Provide a simple CLI that reads commands from stdin and executes them, plus basic unit tests.
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.