From 64996f4b93556fbcba573d986be85b3101fb7962 Mon Sep 17 00:00:00 2001 From: Leonardo Brandenberger Date: Fri, 25 Mar 2022 21:09:27 +0100 Subject: [PATCH 1/3] added comments when exception is thrown in Track --- src/main/java/ch/zhaw/pm2/racetrack/Track.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/ch/zhaw/pm2/racetrack/Track.java b/src/main/java/ch/zhaw/pm2/racetrack/Track.java index bac8f92..61f5459 100644 --- a/src/main/java/ch/zhaw/pm2/racetrack/Track.java +++ b/src/main/java/ch/zhaw/pm2/racetrack/Track.java @@ -115,7 +115,7 @@ public class Track implements TrackSpecification { char possibleCarChar = line.charAt(xPosition); if (!allSpaceTypesAsChar.contains(possibleCarChar)) { if (usedSymbolForCar.contains(possibleCarChar)) { - throw new InvalidTrackFormatException(); + throw new InvalidTrackFormatException("More than one car on track!"); } usedSymbolForCar.add(possibleCarChar); cars.add(new Car(possibleCarChar, new PositionVector(xPosition, yPosition))); @@ -143,12 +143,12 @@ public class Track implements TrackSpecification { } } if (finishLine.size() == 0) { - throw new InvalidTrackFormatException(); + throw new InvalidTrackFormatException("No finish line found!"); } finishTyp = getSpaceType(finishLine.get(0)); for (PositionVector positionVector : finishLine) { if (getSpaceType(positionVector) != finishTyp) { - throw new InvalidTrackFormatException(); + throw new InvalidTrackFormatException("Inconsistent finish line found!"); } } } From 70a2179ccea64511497134b8d3c47ed3c1b35d23 Mon Sep 17 00:00:00 2001 From: romanschenk37 <84532681+romanschenk37@users.noreply.github.com> Date: Fri, 25 Mar 2022 21:14:18 +0100 Subject: [PATCH 2/3] Code Cleanup --- follower/challenge_points.txt | 4 ++++ src/main/java/ch/zhaw/pm2/racetrack/Game.java | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/follower/challenge_points.txt b/follower/challenge_points.txt index d794046..4d7fec6 100644 --- a/follower/challenge_points.txt +++ b/follower/challenge_points.txt @@ -1,3 +1,7 @@ +(X:28, Y:22) +(X:31, Y:22) +(X:34, Y:22) +(X:37, Y:22) (X:40, Y:22) (X:43, Y:22) (X:46, Y:21) diff --git a/src/main/java/ch/zhaw/pm2/racetrack/Game.java b/src/main/java/ch/zhaw/pm2/racetrack/Game.java index 4203a3e..480e8c5 100644 --- a/src/main/java/ch/zhaw/pm2/racetrack/Game.java +++ b/src/main/java/ch/zhaw/pm2/racetrack/Game.java @@ -94,7 +94,7 @@ public class Game implements GameSpecification { } if(selectedFile != null){ try { - moveStrategy = new PathFollowerMoveStrategy(selectedFile, track.getCarPos(currentCarIndex)); + moveStrategy = new PathFollowerMoveStrategy(selectedFile, track.getCarPos(i)); } catch (FileNotFoundException e) { userInterface.printInformation("There is no Point-List implemented. Choose another Strategy!"); } From a002362b622a69b6dfb3d25b3080120da08da45a Mon Sep 17 00:00:00 2001 From: romanschenk37 <84532681+romanschenk37@users.noreply.github.com> Date: Fri, 25 Mar 2022 21:26:56 +0100 Subject: [PATCH 3/3] Code Cleanup --- .../java/ch/zhaw/pm2/racetrack/InvalidFileFormatException.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/ch/zhaw/pm2/racetrack/InvalidFileFormatException.java b/src/main/java/ch/zhaw/pm2/racetrack/InvalidFileFormatException.java index f530593..22b7126 100644 --- a/src/main/java/ch/zhaw/pm2/racetrack/InvalidFileFormatException.java +++ b/src/main/java/ch/zhaw/pm2/racetrack/InvalidFileFormatException.java @@ -4,8 +4,8 @@ package ch.zhaw.pm2.racetrack; * Class for Exception when invalid Fileformat is used. */ public class InvalidFileFormatException extends Exception { - public InvalidFileFormatException(){super();} public InvalidFileFormatException(String errorMessage) { super(errorMessage); } + public InvalidFileFormatException(){super();} }