0
0
LLDsystem_design~10 mins

Restaurant, Menu, Order classes in LLD - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define the Restaurant class with a name attribute.

LLD
class Restaurant:
    def __init__(self, [1]):
        self.name = name
Drag options to blanks, or click blank then click option'
Aname
Blocation
Corder
Dmenu
Attempts:
3 left
💡 Hint
Common Mistakes
Using unrelated parameter names like menu or order.
2fill in blank
medium

Complete the code to add a method that adds a Menu item to the Restaurant.

LLD
class Restaurant:
    def __init__(self, name):
        self.name = name
        self.menu_items = []

    def [1](self, item):
        self.menu_items.append(item)
Drag options to blanks, or click blank then click option'
Aadd_menu_item
Bremove_menu_item
Cget_menu
Dupdate_menu
Attempts:
3 left
💡 Hint
Common Mistakes
Using method names that do not add items like remove or get.
3fill in blank
hard

Fix the error in the Order class constructor to correctly initialize the order_id attribute.

LLD
class Order:
    def __init__(self, [1]):
        self.order_id = order_id
        self.items = []
Drag options to blanks, or click blank then click option'
Aitems
Border_id
Cid
Dorder
Attempts:
3 left
💡 Hint
Common Mistakes
Using a parameter name different from the attribute name causing errors.
4fill in blank
hard

Fill both blanks to create a method in Order that adds a Menu item to the items list.

LLD
class Order:
    def __init__(self, order_id):
        self.order_id = order_id
        self.items = []

    def [1](self, [2]):
        self.items.append(item)
Drag options to blanks, or click blank then click option'
Aadd_item
Bitem
Cremove_item
Dorder
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong method names or parameter names that don't match the code.
5fill in blank
hard

Fill all three blanks to create a method in Menu that returns a dictionary of item names and prices for items priced above a threshold.

LLD
class Menu:
    def __init__(self):
        self.items = {}

    def get_expensive_items(self, price_threshold):
        return {name: [1] for name, [2] in self.items.items() if [3] > price_threshold}
Drag options to blanks, or click blank then click option'
Aprice
Ditem
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong variable names or mixing keys and values.