feat: correction plupart des bug

- TODO: hybridCar a regler
This commit is contained in:
2025-12-18 21:00:13 +01:00
parent d210eedb5a
commit 6c75a5363f
11 changed files with 44 additions and 38 deletions

View File

@@ -69,24 +69,18 @@ public class Game {
}
public Game build() {
Game game = new Game();
Game game = new Game(this.map, this.time, this.OBSERVERS);
for (Game.Observer observer : this.OBSERVERS) {
for (Game.Observer observer : new ArrayList<>(this.OBSERVERS)) {
switch (observer) {
case GameView gameView -> {
gameView.setGame(game);
}
case Car car -> {
car.setMap(map);
}
default -> {
}
}
}
game.map = this.map;
game.time = this.time;
game.observers = this.OBSERVERS;
return game;
}
}
@@ -104,6 +98,16 @@ public class Game {
this.map = map;
this.time = time;
this.observers = observer;
for (Game.Observer obs : this.observers) {
switch (obs) {
case Car car -> {
car.setMap(map);
}
default -> {
}
}
}
}
public Game addObserver(Observer o) {
@@ -153,6 +157,7 @@ public class Game {
e.printStackTrace();
System.exit(1);
}
}
public synchronized boolean togglePause() {