NewWork mode: your Claude Code or Codex on work calls, answering from your project's codeSkip to content
Middle+83 views

Не изменяя существующий класс и команды лифта, добавьте безопасное перемещение: перед движением нужно убедиться, что двери закрыты.

Practice

AI answer

Add a check immediately before movement begins, and do not call the movement command if the doors are not closed. The existing class and commands can remain unchanged; the specific method names depend on the code provided. For example:

def move_safely(elevator, destination):
    if not elevator.doors_are_closed():
        raise RuntimeError("Cannot move: elevator doors are open")

    elevator.move_to(destination)

If commands are represented as strings or command objects, the same check should be placed in the shared execution path for the movement command. The check must run immediately before movement so the door state does not become stale between the check and the start of movement.