changes in Method initphase
added Method printInformation in UserInterface.java
This commit is contained in:
@@ -29,42 +29,50 @@ public class Game implements GameSpecification {
|
||||
userInterface = new UserInterface(welcometext);
|
||||
}
|
||||
|
||||
public void initphase() throws InvalidTrackFormatException, FileNotFoundException {
|
||||
|
||||
public boolean initphase() throws InvalidTrackFormatException, FileNotFoundException {
|
||||
File folder = new File("tracks");
|
||||
File[] listOfFiles = folder.listFiles();
|
||||
List<String> tracks = new ArrayList<>();
|
||||
for(File file : listOfFiles){
|
||||
tracks.add(file.getName());
|
||||
}
|
||||
File selectedTrack = listOfFiles[userInterface.selectOption("Select Track file", tracks)];
|
||||
track = new Track(selectedTrack);
|
||||
List<String> moveStrategies = new ArrayList<>();
|
||||
moveStrategies.add("Do not move Strategy");
|
||||
moveStrategies.add("User Move Strategy");
|
||||
moveStrategies.add("Move List Strategy");
|
||||
moveStrategies.add("Path Follow Move Strategy");
|
||||
for(int i = 0; i < track.getCarCount() ; i++ ){
|
||||
int moveStrategie = userInterface.selectOption(
|
||||
"Select Strategy for Car " + i + " (" + track.getCarId(i) + ")", moveStrategies);
|
||||
switch(moveStrategie) { //TODO: set Movestrategy with method in Track
|
||||
case 1:
|
||||
track.getCar(i).setMoveStrategy(new DoNotMoveStrategy()); //TODO: add Arguments
|
||||
break;
|
||||
case 2:
|
||||
track.getCar(i).setMoveStrategy(new UserMoveStrategy()); //TODO: add Arguments
|
||||
break;
|
||||
case 3:
|
||||
track.getCar(i).setMoveStrategy(new MoveListStrategy()); //TODO: add Arguments
|
||||
break;
|
||||
case 4:
|
||||
track.getCar(i).setMoveStrategy(new PathFollowerMoveStrategy()); //TODO: add Arguments
|
||||
break;
|
||||
if(listOfFiles.length > 0) {
|
||||
List<String> tracks = new ArrayList<>();
|
||||
for(File file : listOfFiles){
|
||||
tracks.add(file.getName());
|
||||
}
|
||||
File selectedTrack = listOfFiles[userInterface.selectOption("Select Track file", tracks)];
|
||||
try {
|
||||
track = new Track(selectedTrack);
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
List<String> moveStrategies = new ArrayList<>();
|
||||
moveStrategies.add("Do not move Strategy");
|
||||
moveStrategies.add("User Move Strategy");
|
||||
moveStrategies.add("Move List Strategy");
|
||||
moveStrategies.add("Path Follow Move Strategy");
|
||||
for(int i = 0; i < track.getCarCount() ; i++ ) {
|
||||
int moveStrategie = userInterface.selectOption(
|
||||
"Select Strategy for Car " + i + " (" + track.getCarId(i) + ")", moveStrategies);
|
||||
switch (moveStrategie) { //TODO: set Movestrategy with method in Track
|
||||
case 1:
|
||||
track.getCar(i).setMoveStrategy(new DoNotMoveStrategy()); //TODO: add Arguments
|
||||
break;
|
||||
case 2:
|
||||
track.getCar(i).setMoveStrategy(new UserMoveStrategy()); //TODO: add Arguments
|
||||
break;
|
||||
case 3:
|
||||
track.getCar(i).setMoveStrategy(new MoveListStrategy()); //TODO: add Arguments
|
||||
break;
|
||||
case 4:
|
||||
track.getCar(i).setMoveStrategy(new PathFollowerMoveStrategy()); //TODO: add Arguments
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
userInterface.printInformation("No Trackfile found!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
userInterface.printTrack(track);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user