Merge remote-tracking branch 'origin/main'

This commit is contained in:
Andrin Fassbind 2022-03-25 21:48:25 +01:00
commit 00cb917842
4 changed files with 9 additions and 5 deletions

View File

@ -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)

View File

@ -99,7 +99,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) {
e.printStackTrace();
userInterface.printInformation("There is no Point-List implemented. Choose another Strategy!");

View File

@ -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();}
}

View File

@ -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!");
}
}
}