javadocs of Methods to create Movestrategy

This commit is contained in:
romanschenk37 2022-03-25 22:15:19 +01:00
parent 976b153edb
commit cf9301d4b8
1 changed files with 18 additions and 4 deletions

View File

@ -69,10 +69,10 @@ public class Game implements GameSpecification {
moveStrategy = new UserMoveStrategy(userInterface, carIndex, track.getCarId(carIndex)); moveStrategy = new UserMoveStrategy(userInterface, carIndex, track.getCarId(carIndex));
break; break;
case 2: case 2:
moveStrategy = getMoveListStrategy(selectedTrack, carIndex, moveStrategy); moveStrategy = getMoveListStrategy(selectedTrack, carIndex);
break; break;
case 3: case 3:
moveStrategy = getPathFollowerMoveStrategy(selectedTrack, carIndex, moveStrategy); moveStrategy = getPathFollowerMoveStrategy(selectedTrack, carIndex);
break; break;
case 4: 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; File selectedFile = null;
MoveStrategy moveStrategy = null;
for (File file : config.getFollowerDirectory().listFiles()) { for (File file : config.getFollowerDirectory().listFiles()) {
if (file.toString().equals(config.getFollowerDirectory().toString() + "\\" + selectedTrack.getName().split("\\.")[0] + "_points.txt")) { if (file.toString().equals(config.getFollowerDirectory().toString() + "\\" + selectedTrack.getName().split("\\.")[0] + "_points.txt")) {
selectedFile = file; selectedFile = file;
@ -112,8 +119,15 @@ public class Game implements GameSpecification {
return moveStrategy; 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; File selectedFile = null;
MoveStrategy moveStrategy = null;
for (File file : config.getMoveDirectory().listFiles()) { for (File file : config.getMoveDirectory().listFiles()) {
if (file.toString().equals(config.getMoveDirectory().toString() + "\\" + selectedTrack.getName().split("\\.")[0] + "-car-" + track.getCar(carIndex).getID() + ".txt")) { if (file.toString().equals(config.getMoveDirectory().toString() + "\\" + selectedTrack.getName().split("\\.")[0] + "-car-" + track.getCar(carIndex).getID() + ".txt")) {
selectedFile = file; selectedFile = file;