From 7d22e586d17a3017a5f41738bf181555bdea481f Mon Sep 17 00:00:00 2001 From: DylanVsn <43576618+DylanVsn@users.noreply.github.com> Date: Sat, 19 Oct 2019 22:25:39 +0200 Subject: [PATCH] bon, je crois que ce sera tout --- src/gui/ElevatorCanvas.java | 2 +- src/simulation/Simulation.java | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/gui/ElevatorCanvas.java b/src/gui/ElevatorCanvas.java index 3e266e0..f43796d 100644 --- a/src/gui/ElevatorCanvas.java +++ b/src/gui/ElevatorCanvas.java @@ -50,7 +50,7 @@ class ElevatorCanvas extends JPanel { g.setColor(Color.GRAY); int nbFloors = elevator.getNbFloors(); for (int i = 0; i < nbFloors; i++) { - int y = i * ((int) DIMENSIONS.getHeight() / (nbFloors - 1)); + int y = HEIGHT + i * ((int) (DIMENSIONS.getHeight() - HEIGHT) / (nbFloors - 1)); g.fillRect(0, y-1, WIDTH, 3); } diff --git a/src/simulation/Simulation.java b/src/simulation/Simulation.java index 580205d..d3b1d97 100644 --- a/src/simulation/Simulation.java +++ b/src/simulation/Simulation.java @@ -47,6 +47,7 @@ public class Simulation implements ElevatorListener { if (haveToWait) { long t1 = System.nanoTime(); elevator.stop(); + running = false; while ((System.nanoTime() - t1) / 1_000_000_000 < secondToWait); } update(); @@ -69,20 +70,24 @@ public class Simulation implements ElevatorListener { if (next == -1 || next == currentFloor) { System.out.println("Stopping."); elevator.stop(); + running = false; return; } else if (next > currentFloor) { System.out.print("Going up."); + running = true; elevator.goUp(); } else if (next < currentFloor) { System.out.print("Going down."); + running = true; elevator.goDown(); } if (next == currentFloor + 1 || next == currentFloor - 1) { System.out.print("\b (slowly)."); + running = true; elevator.stopNextFloor(); } System.out.println("\n");