diff --git a/src/main/java/ch/zhaw/pm2/racetrack/Game.java b/src/main/java/ch/zhaw/pm2/racetrack/Game.java index deac44a..8f6fd94 100644 --- a/src/main/java/ch/zhaw/pm2/racetrack/Game.java +++ b/src/main/java/ch/zhaw/pm2/racetrack/Game.java @@ -69,10 +69,10 @@ public class Game implements GameSpecification { moveStrategy = new UserMoveStrategy(userInterface, carIndex, track.getCarId(carIndex)); break; case 2: - moveStrategy = getMoveListStrategy(selectedTrack, carIndex, moveStrategy); + moveStrategy = getMoveListStrategy(selectedTrack, carIndex); break; case 3: - moveStrategy = getPathFollowerMoveStrategy(selectedTrack, carIndex, moveStrategy); + moveStrategy = getPathFollowerMoveStrategy(selectedTrack, carIndex); break; case 4: @@ -89,8 +89,15 @@ public class Game implements GameSpecification { } } - private MoveStrategy getPathFollowerMoveStrategy(File selectedTrack, int carIndex, MoveStrategy moveStrategy) { + /** + * creates a PathFollowerMoveStrategy for a specific track and a specific car + * @param selectedTrack the selected Track + * @param carIndex the Index of the car + * @return the created Movestrategy, null if File not found or invalid + */ + private MoveStrategy getPathFollowerMoveStrategy(File selectedTrack, int carIndex) { File selectedFile = null; + MoveStrategy moveStrategy = null; for (File file : config.getFollowerDirectory().listFiles()) { if (file.toString().equals(config.getFollowerDirectory().toString() + "\\" + selectedTrack.getName().split("\\.")[0] + "_points.txt")) { selectedFile = file; @@ -112,8 +119,15 @@ public class Game implements GameSpecification { return moveStrategy; } - private MoveStrategy getMoveListStrategy(File selectedTrack, int carIndex, MoveStrategy moveStrategy) { + /** + * creates a MoveListStrategy for a specific track and a specific car + * @param selectedTrack the selected Track + * @param carIndex the Index of the car + * @return the created Movestrategy, null if File not found or invalid + */ + private MoveStrategy getMoveListStrategy(File selectedTrack, int carIndex) { File selectedFile = null; + MoveStrategy moveStrategy = null; for (File file : config.getMoveDirectory().listFiles()) { if (file.toString().equals(config.getMoveDirectory().toString() + "\\" + selectedTrack.getName().split("\\.")[0] + "-car-" + track.getCar(carIndex).getID() + ".txt")) { selectedFile = file;