MoveListStrategy implemented
This commit is contained in:
parent
c30d7a2988
commit
837297cd31
|
@ -47,28 +47,31 @@ public class Game implements GameSpecification {
|
||||||
moveStrategies.add("Move List Strategy");
|
moveStrategies.add("Move List Strategy");
|
||||||
moveStrategies.add("Path Follow Move Strategy");
|
moveStrategies.add("Path Follow Move Strategy");
|
||||||
for (int i = 0; i < track.getCarCount(); i++) {
|
for (int i = 0; i < track.getCarCount(); i++) {
|
||||||
int moveStrategie = userInterface.selectOption(
|
while(track.getCar(i).getMoveStrategy() == null) {
|
||||||
"Select Strategy for Car " + i + " (" + track.getCarId(i) + ")", moveStrategies);
|
int moveStrategie = userInterface.selectOption(
|
||||||
switch (moveStrategie + 1) {
|
"Select Strategy for Car " + i + " (" + track.getCarId(i) + ")", moveStrategies);
|
||||||
case 1:
|
switch (moveStrategie + 1) {
|
||||||
track.getCar(i).setMoveStrategy(new DoNotMoveStrategy());
|
case 1:
|
||||||
break;
|
track.getCar(i).setMoveStrategy(new DoNotMoveStrategy());
|
||||||
case 2:
|
break;
|
||||||
track.getCar(i).setMoveStrategy(new UserMoveStrategy(userInterface, i, track.getCarId(i)));
|
case 2:
|
||||||
break;
|
track.getCar(i).setMoveStrategy(new UserMoveStrategy(userInterface, i, track.getCarId(i)));
|
||||||
case 3:
|
break;
|
||||||
String path = ".\\moves\\ " + selectedTrack.getName().split("\\.")[0] + "-car-" + track.getCar(i).getID() + ".txt";
|
case 3:
|
||||||
try {
|
String path = ".\\moves\\" + selectedTrack.getName().split("\\.")[0] + "-car-" + track.getCar(i).getID() + ".txt";
|
||||||
MoveStrategy moveStrategy = new MoveListStrategy(path);
|
System.out.println(path);
|
||||||
track.getCar(i).setMoveStrategy(moveStrategy);
|
try {
|
||||||
} catch (FileNotFoundException e) {
|
MoveStrategy moveStrategy = new MoveListStrategy(path);
|
||||||
//TODO: what if not valid
|
track.getCar(i).setMoveStrategy(moveStrategy);
|
||||||
}
|
} catch (FileNotFoundException e) {
|
||||||
//TODO: Backslash kompatibel für Linux
|
userInterface.printInformation("There is no MoveList implemented. Choose another Strategy!");
|
||||||
break;
|
}
|
||||||
case 4:
|
//TODO: Backslash kompatibel für Linux
|
||||||
track.getCar(i).setMoveStrategy(new PathFollowerMoveStrategy()); //TODO: add Arguments
|
break;
|
||||||
break;
|
case 4:
|
||||||
|
track.getCar(i).setMoveStrategy(new PathFollowerMoveStrategy()); //TODO: add Arguments
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue