From 64996f4b93556fbcba573d986be85b3101fb7962 Mon Sep 17 00:00:00 2001 From: Leonardo Brandenberger Date: Fri, 25 Mar 2022 21:09:27 +0100 Subject: [PATCH] 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!"); } } }