Bird
0
0
LLDsystem_design~10 mins

Elevator, Floor, Request 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 Elevator class with a constructor.

LLD
class Elevator:
    def __init__(self, [1]):
        self.current_floor = 0
        self.requests = []
Drag options to blanks, or click blank then click option'
Afloors
Bid
Cspeed
Dcapacity
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'capacity' or 'speed' as the only constructor parameter.
2fill in blank
medium

Complete the code to add a method that adds a floor request to the elevator.

LLD
class Elevator:
    def add_request(self, [1]):
        self.requests.append(request)
Drag options to blanks, or click blank then click option'
Arequest
Bfloor_number
Cdestination
Dfloor
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'floor_number' or 'destination' which are not objects.
3fill in blank
hard

Fix the error in the Floor class constructor parameter name.

LLD
class Floor:
    def __init__(self, [1]):
        self.number = number
        self.waiting_requests = []
Drag options to blanks, or click blank then click option'
Afloor_num
Bfloor
CfloorNumber
Dnumber
Attempts:
3 left
💡 Hint
Common Mistakes
Using different parameter names than the assigned variable.
4fill in blank
hard

Fill both blanks to complete the Request class with source and destination floors.

LLD
class Request:
    def __init__(self, [1], [2]):
        self.source = source
        self.destination = destination
Drag options to blanks, or click blank then click option'
Asource
Bdestination
Cstart
Dend
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'start' or 'end' which do not match attribute names.
5fill in blank
hard

Fill all three blanks to create a method that checks if the elevator is idle (no requests and at floor 0).

LLD
class Elevator:
    def is_idle(self):
        return len(self.[1]) == 0 and self.[2] == [3]
Drag options to blanks, or click blank then click option'
Arequests
Bcurrent_floor
C0
Dfloors
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'floors' or wrong attribute names.