From 74a83e790a2ddedaa15d2a4925ae6dcd6a8dc59b Mon Sep 17 00:00:00 2001 From: romanschenk37 <84532681+romanschenk37@users.noreply.github.com> Date: Fri, 18 Mar 2022 10:55:31 +0100 Subject: [PATCH] fixes in Game.java Method switchToNextActiveCar --- src/main/java/ch/zhaw/pm2/racetrack/Game.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/ch/zhaw/pm2/racetrack/Game.java b/src/main/java/ch/zhaw/pm2/racetrack/Game.java index 56fbf31..457d278 100644 --- a/src/main/java/ch/zhaw/pm2/racetrack/Game.java +++ b/src/main/java/ch/zhaw/pm2/racetrack/Game.java @@ -197,9 +197,12 @@ public class Game implements GameSpecification { @Override public void switchToNextActiveCar() { do { - if (currentCarIndex++ > track.getCarCount()) { + if ((currentCarIndex + 1) == track.getCarCount()) { currentCarIndex = 0; } + else { + currentCarIndex ++; + } } while (track.getCar(currentCarIndex).isCrashed()); // TODO: evtl andere Kapselung }