diff --git a/src/simulation/Elevator.java b/src/simulation/Elevator.java index 81dde43..4c6de7d 100644 --- a/src/simulation/Elevator.java +++ b/src/simulation/Elevator.java @@ -12,8 +12,6 @@ public class Elevator { private double floorHeight; private double step; private double height; - // private int currentFloor = 0; - // private boolean betweenFloors = false; /* Between currentFloor and the one above it. */ private Direction direction = Direction.NONE; private boolean stoppingNextFloor = false; private boolean emergency = false; @@ -61,69 +59,24 @@ public class Elevator { public void update() { if (emergency) return; - // int prevFloor = (int) Math.floor(height / floorHeight); switch (direction) { - // case DOWN: - // height -= step; - - // /* Bottom reached. */ - // if (height < step) { - // height = 0; - // direction = Direction.NONE; - // } - - // /* Passed a floor, invoke the listener. */ - // if (Math.floor(height / floorHeight) < prevFloor && listener != null) { - // listener.floorChange(Direction.DOWN); - // } - // // /* Go halfway below. */ - // // if (!betweenFloors) currentFloor--; - // // betweenFloors = !betweenFloors; - // break; - // case UP: - // height += step; - - // /* Top reached. */ - // if (height > 1-step) { - // height = 1; - // direction = Direction.NONE; - // } - - // /* Passed a floor, invoke the listener. */ - // if (Math.floor(height / floorHeight) > prevFloor && listener != null) { - // listener.floorChange(Direction.UP); - // } - // // /* Go halfway above. */ - // // if (betweenFloors) currentFloor++; - // // betweenFloors = !betweenFloors; - // break; case DOWN: height -= step; - if (height % floorHeight < step && listener != null) { listener.floorChange(Direction.DOWN); } break; - - case UP: - height += step; - if (height % floorHeight < step && listener != null) { - listener.floorChange(Direction.UP); - } - break; + case UP: + height += step; + if (height % floorHeight < step && listener != null) { + listener.floorChange(Direction.UP); + } + break; default: break; } } - // public int getCurrentFloor() { - // return currentFloor; - // } - - // public boolean getBetweenFloors() { - // return betweenFloors; - // } - public Direction getDirection() { return direction; } diff --git a/src/simulation/Simulation.java b/src/simulation/Simulation.java index 79e0725..58d0b34 100644 --- a/src/simulation/Simulation.java +++ b/src/simulation/Simulation.java @@ -46,11 +46,12 @@ public class Simulation implements ElevatorListener { } public void emergency() { - System.out.println("Emergency declared."); + elevator.emergencyStop(); } public void cancelEmergency() { - System.out.println("Emergency cancelled."); + queue = new BasicInstructionQueue(); + elevator.cancelEmergency(); } private void update() {