0
0
LLDsystem_design~10 mins

Hotel, Room, Booking 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 Hotel class with a name attribute.

LLD
class Hotel:
    def __init__(self, [1]):
        self.name = name
Drag options to blanks, or click blank then click option'
Alocation
Bbooking
Cname
Drooms
Attempts:
3 left
💡 Hint
Common Mistakes
Using a wrong parameter name like location or rooms instead of name.
2fill in blank
medium

Complete the code to add a method in Room class that returns the room number.

LLD
class Room:
    def __init__(self, number):
        self.number = number

    def get_[1](self):
        return self.number
Drag options to blanks, or click blank then click option'
Aprice
Btype
Cavailability
Dnumber
Attempts:
3 left
💡 Hint
Common Mistakes
Naming the method incorrectly like get_price or get_type.
3fill in blank
hard

Fix the error in Booking class constructor to correctly assign the room and guest.

LLD
class Booking:
    def __init__(self, room, guest):
        self.room = [1]
        self.guest = guest
Drag options to blanks, or click blank then click option'
Aself.guest
Broom
Cself.room
Dguest
Attempts:
3 left
💡 Hint
Common Mistakes
Assigning guest to self.room by mistake.
4fill in blank
hard

Fill both blanks to create a method in Hotel class that adds a Room object to its rooms list.

LLD
class Hotel:
    def __init__(self, name):
        self.name = name
        self.rooms = []

    def add_room(self, [1]):
        self.rooms.[2](room)
Drag options to blanks, or click blank then click option'
Aroom
Brooms
Cappend
Dadd
Attempts:
3 left
💡 Hint
Common Mistakes
Using rooms as parameter or add instead of append.
5fill in blank
hard

Fill all three blanks to create a method in Booking class that checks if the booking is for a specific room number.

LLD
class Booking:
    def __init__(self, room, guest):
        self.room = room
        self.guest = guest

    def is_for_room(self, [1]):
        return self.room.[2] == [3]
Drag options to blanks, or click blank then click option'
Aroom_number
Bnumber
Dguest
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong parameter names or comparing with guest instead of room number.