From e5f45b7bb140e2c41488c500bc76311ce880f287 Mon Sep 17 00:00:00 2001 From: romanschenk37 <84532681+romanschenk37@users.noreply.github.com> Date: Fri, 18 Mar 2022 10:37:53 +0100 Subject: [PATCH] fixes in Game.java and UserInterface.java --- src/main/java/ch/zhaw/pm2/racetrack/Game.java | 1 + src/main/java/ch/zhaw/pm2/racetrack/Main.java | 5 +++-- src/main/java/ch/zhaw/pm2/racetrack/UserInterface.java | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/ch/zhaw/pm2/racetrack/Game.java b/src/main/java/ch/zhaw/pm2/racetrack/Game.java index 0b7595f..48bd162 100644 --- a/src/main/java/ch/zhaw/pm2/racetrack/Game.java +++ b/src/main/java/ch/zhaw/pm2/racetrack/Game.java @@ -187,6 +187,7 @@ public class Game implements GameSpecification { if(winner != NO_WINNER) { return winner; } + switchToNextActiveCar(); } while (!allCarsCrashed()); return NO_WINNER; } diff --git a/src/main/java/ch/zhaw/pm2/racetrack/Main.java b/src/main/java/ch/zhaw/pm2/racetrack/Main.java index 0817f16..1364d4f 100644 --- a/src/main/java/ch/zhaw/pm2/racetrack/Main.java +++ b/src/main/java/ch/zhaw/pm2/racetrack/Main.java @@ -7,10 +7,11 @@ public class Main { public static void main(String[] args) throws InvalidTrackFormatException, FileNotFoundException, PositionVectorNotValid { UserInterface userInterface = new UserInterface("Hello and Welcome"); Game game = new Game(userInterface); - + int winner = 0; if(game.initPhase()){ - int winner = game.gamePhase(); + winner = game.gamePhase(); } + userInterface.printInformation("Winner: " + winner); } } diff --git a/src/main/java/ch/zhaw/pm2/racetrack/UserInterface.java b/src/main/java/ch/zhaw/pm2/racetrack/UserInterface.java index b67d6f4..c19e7ca 100644 --- a/src/main/java/ch/zhaw/pm2/racetrack/UserInterface.java +++ b/src/main/java/ch/zhaw/pm2/racetrack/UserInterface.java @@ -52,7 +52,7 @@ public class UserInterface { */ public PositionVector.Direction selectDirection(int playingCarIndex, char playingCarID) { PositionVector.Direction direction = null; - textTerminal.println("Playing Car " + playingCarIndex + ": " + playingCarIndex); + textTerminal.println("Playing Car " + playingCarIndex + ": " + playingCarID); textTerminal.println("Directions are based on the number pad:"); textTerminal.println("7 8 9 7=up-left, 8=up, 9=up-right"); textTerminal.println("4 5 6 4=left, 5=no acceleration, 6=right");