bon, je crois que ce sera tout
This commit is contained in:
parent
55e8c1ea0f
commit
7d22e586d1
@ -50,7 +50,7 @@ class ElevatorCanvas extends JPanel {
|
|||||||
g.setColor(Color.GRAY);
|
g.setColor(Color.GRAY);
|
||||||
int nbFloors = elevator.getNbFloors();
|
int nbFloors = elevator.getNbFloors();
|
||||||
for (int i = 0; i < nbFloors; i++) {
|
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);
|
g.fillRect(0, y-1, WIDTH, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,6 +47,7 @@ public class Simulation implements ElevatorListener {
|
|||||||
if (haveToWait) {
|
if (haveToWait) {
|
||||||
long t1 = System.nanoTime();
|
long t1 = System.nanoTime();
|
||||||
elevator.stop();
|
elevator.stop();
|
||||||
|
running = false;
|
||||||
while ((System.nanoTime() - t1) / 1_000_000_000 < secondToWait);
|
while ((System.nanoTime() - t1) / 1_000_000_000 < secondToWait);
|
||||||
}
|
}
|
||||||
update();
|
update();
|
||||||
@ -69,20 +70,24 @@ public class Simulation implements ElevatorListener {
|
|||||||
if (next == -1 || next == currentFloor) {
|
if (next == -1 || next == currentFloor) {
|
||||||
System.out.println("Stopping.");
|
System.out.println("Stopping.");
|
||||||
elevator.stop();
|
elevator.stop();
|
||||||
|
running = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (next > currentFloor) {
|
else if (next > currentFloor) {
|
||||||
System.out.print("Going up.");
|
System.out.print("Going up.");
|
||||||
|
running = true;
|
||||||
elevator.goUp();
|
elevator.goUp();
|
||||||
}
|
}
|
||||||
else if (next < currentFloor) {
|
else if (next < currentFloor) {
|
||||||
System.out.print("Going down.");
|
System.out.print("Going down.");
|
||||||
|
running = true;
|
||||||
elevator.goDown();
|
elevator.goDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (next == currentFloor + 1 || next == currentFloor - 1) {
|
if (next == currentFloor + 1 || next == currentFloor - 1) {
|
||||||
System.out.print("\b (slowly).");
|
System.out.print("\b (slowly).");
|
||||||
|
running = true;
|
||||||
elevator.stopNextFloor();
|
elevator.stopNextFloor();
|
||||||
}
|
}
|
||||||
System.out.println("\n");
|
System.out.println("\n");
|
||||||
|
Reference in New Issue
Block a user