Skip to content

Commit 873fc0c

Browse files
committed
fix: do not send invalid An
1 parent 2b5c17c commit 873fc0c

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

cmd/droopy/main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,9 @@ func (e *Elevator) Handle(cmd string) string {
319319

320320
if e.eventTime == ticksPerFloor-approachTicks {
321321
floor := nextFloor(e.floor, e.motor)
322-
return fmt.Sprintf("A%d", floor)
322+
if floor >= 1 && floor <= MaxFloor {
323+
return fmt.Sprintf("A%d", floor)
324+
}
323325
}
324326
}
325327
default:

0 commit comments

Comments
 (0)