Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is the main responsibility of the Restaurant class in a system design?
The Restaurant class manages the overall restaurant details, including its name, location, and the menus it offers. It acts as a container for menus and handles operations like adding or removing menus.
Click to reveal answer
beginner
What does the Menu class typically represent and contain?
The Menu class represents a collection of MenuItems offered by the restaurant. It contains details like the menu name (e.g., Breakfast, Dinner) and a list of MenuItems with their prices and descriptions.
Click to reveal answer
beginner
What is the role of the Order class in the system?
The Order class tracks customer orders. It contains ordered items, quantities, order status (e.g., pending, completed), and calculates the total price. It connects the customer choices to the restaurant's menu.
Click to reveal answer
intermediate
How do the Restaurant, Menu, and Order classes interact in a typical flow?
The Restaurant holds multiple Menus. Each Menu has MenuItems. When a customer places an Order, it references MenuItems from a Menu in the Restaurant. The Order calculates totals based on MenuItem prices.
Click to reveal answer
intermediate
Why is it important to separate Menu and Order classes in system design?
Separating Menu and Order classes allows independent management of the menu (items and prices) and customer orders. This separation supports scalability, easier updates to menus, and clear tracking of orders without mixing concerns.
Click to reveal answer
Which class should contain the list of available dishes in a restaurant system?
ARestaurant
BOrder
CMenu
DCustomer
✗ Incorrect
The Menu class holds the list of available dishes (MenuItems) offered by the restaurant.
What does the Order class primarily track?
AEmployee schedules
BRestaurant location details
CMenu item prices
DCustomer orders and their status
✗ Incorrect
The Order class tracks customer orders, including items ordered and their status.
If you want to add a new dish to the restaurant, which class should you update?
AInvoice
BMenu
CRestaurant
DOrder
✗ Incorrect
New dishes are added to the Menu class as MenuItems.
Which class is responsible for calculating the total price of an order?
AOrder
BMenu
CRestaurant
DPayment
✗ Incorrect
The Order class calculates the total price based on the ordered MenuItems and their quantities.
Why should Menu and Order be separate classes?
ATo keep menu management and order tracking independent
BTo combine all data in one place
CTo reduce the number of classes
DTo avoid using databases
✗ Incorrect
Separating Menu and Order keeps menu management and order tracking independent, improving clarity and scalability.
Explain how the Restaurant, Menu, and Order classes work together in a restaurant system.
Think about how a customer chooses items and places an order.
You got /5 concepts.
Describe why separating concerns between Menu and Order classes is beneficial in system design.
Consider what would happen if menu and orders were mixed in one class.
You got /4 concepts.
Practice
(1/5)
1. Which class should primarily hold the list of available food items and their prices in a restaurant system?
easy
A. Restaurant
B. Menu
C. Order
D. Customer
Solution
Step 1: Understand the role of Menu class
The Menu class is designed to store food items and their prices, acting as the restaurant's catalog.
Step 2: Differentiate from other classes
Order tracks customer requests, Restaurant manages overall operations, Customer represents the diner. Only Menu holds items and prices.
Final Answer:
Menu -> Option B
Quick Check:
Menu = items and prices [OK]
Hint: Menu holds items and prices, not orders or customers [OK]
Common Mistakes:
Confusing Order with Menu
Thinking Restaurant holds item prices
Assuming Customer stores menu data
2. Which of the following is the correct way to add a new item to the Menu class in a typical object-oriented design?
easy
A. menu.addItem('Pizza', 12.99)
B. Menu.add('Pizza', 12.99)
C. menu.insertItem('Pizza', 12.99)
D. addItem(menu, 'Pizza', 12.99)
Solution
Step 1: Identify instance method usage
Adding an item to a Menu instance uses the instance method, so calling menu.addItem(...) is correct.
Step 2: Eliminate incorrect syntax
Menu.add(...) suggests a static method which is unlikely; insertItem is not standard; addItem(menu, ...) is procedural, not OOP style.
Final Answer:
menu.addItem('Pizza', 12.99) -> Option A
Quick Check:
Instance method call = menu.addItem(...) [OK]
Hint: Use instance.method() to add items, not static or procedural calls [OK]
Common Mistakes:
Using static method call instead of instance method
Confusing method names
Calling functions outside class context
3. Given the following code snippet, what will be the total cost of the order?
menu = Menu()
menu.addItem('Burger', 5.0)
menu.addItem('Fries', 2.5)
order = Order(menu)
order.addItem('Burger', 2)
order.addItem('Fries', 3)
total = order.calculateTotal()