bon, je crois que ce sera tout

This commit is contained in:
DylanVsn 2019-10-19 22:25:39 +02:00
parent 55e8c1ea0f
commit 7d22e586d1
2 changed files with 6 additions and 1 deletions

View File

@ -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);
}

View File

@ -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");