Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
00cb917842
|
@ -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:40, Y:22)
|
||||||
(X:43, Y:22)
|
(X:43, Y:22)
|
||||||
(X:46, Y:21)
|
(X:46, Y:21)
|
||||||
|
|
|
@ -99,7 +99,7 @@ public class Game implements GameSpecification {
|
||||||
}
|
}
|
||||||
if (selectedFile != null) {
|
if (selectedFile != null) {
|
||||||
try {
|
try {
|
||||||
moveStrategy = new PathFollowerMoveStrategy(selectedFile, track.getCarPos(currentCarIndex));
|
moveStrategy = new PathFollowerMoveStrategy(selectedFile, track.getCarPos(i));
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
userInterface.printInformation("There is no Point-List implemented. Choose another Strategy!");
|
userInterface.printInformation("There is no Point-List implemented. Choose another Strategy!");
|
||||||
|
|
|
@ -4,8 +4,8 @@ package ch.zhaw.pm2.racetrack;
|
||||||
* Class for Exception when invalid Fileformat is used.
|
* Class for Exception when invalid Fileformat is used.
|
||||||
*/
|
*/
|
||||||
public class InvalidFileFormatException extends Exception {
|
public class InvalidFileFormatException extends Exception {
|
||||||
public InvalidFileFormatException(){super();}
|
|
||||||
public InvalidFileFormatException(String errorMessage) {
|
public InvalidFileFormatException(String errorMessage) {
|
||||||
super(errorMessage);
|
super(errorMessage);
|
||||||
}
|
}
|
||||||
|
public InvalidFileFormatException(){super();}
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,7 +115,7 @@ public class Track implements TrackSpecification {
|
||||||
char possibleCarChar = line.charAt(xPosition);
|
char possibleCarChar = line.charAt(xPosition);
|
||||||
if (!allSpaceTypesAsChar.contains(possibleCarChar)) {
|
if (!allSpaceTypesAsChar.contains(possibleCarChar)) {
|
||||||
if (usedSymbolForCar.contains(possibleCarChar)) {
|
if (usedSymbolForCar.contains(possibleCarChar)) {
|
||||||
throw new InvalidTrackFormatException();
|
throw new InvalidTrackFormatException("More than one car on track!");
|
||||||
}
|
}
|
||||||
usedSymbolForCar.add(possibleCarChar);
|
usedSymbolForCar.add(possibleCarChar);
|
||||||
cars.add(new Car(possibleCarChar, new PositionVector(xPosition, yPosition)));
|
cars.add(new Car(possibleCarChar, new PositionVector(xPosition, yPosition)));
|
||||||
|
@ -143,12 +143,12 @@ public class Track implements TrackSpecification {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (finishLine.size() == 0) {
|
if (finishLine.size() == 0) {
|
||||||
throw new InvalidTrackFormatException();
|
throw new InvalidTrackFormatException("No finish line found!");
|
||||||
}
|
}
|
||||||
finishTyp = getSpaceType(finishLine.get(0));
|
finishTyp = getSpaceType(finishLine.get(0));
|
||||||
for (PositionVector positionVector : finishLine) {
|
for (PositionVector positionVector : finishLine) {
|
||||||
if (getSpaceType(positionVector) != finishTyp) {
|
if (getSpaceType(positionVector) != finishTyp) {
|
||||||
throw new InvalidTrackFormatException();
|
throw new InvalidTrackFormatException("Inconsistent finish line found!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue