LLD - Design — Elevator System
In this elevator state machine code, what is the bug causing the elevator to never open doors?
current_state = 'Idle'
def callElevator():
global current_state
if current_state == 'Idle':
current_state = 'Moving'
def arriveFloor():
global current_state
if current_state == 'Moving':
current_state = 'Idle' # Bug here
def openDoor():
global current_state
if current_state == 'DoorOpen':
current_state = 'Idle'