created Method initphase in Game.java

This commit is contained in:
romanschenk37 2022-03-10 15:18:08 +01:00
parent d6a46f3cae
commit 4ebe8cb1ed
1 changed files with 18 additions and 0 deletions

View File

@ -2,6 +2,8 @@ package ch.zhaw.pm2.racetrack;
import ch.zhaw.pm2.racetrack.given.GameSpecification; import ch.zhaw.pm2.racetrack.given.GameSpecification;
import java.io.File;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import static ch.zhaw.pm2.racetrack.PositionVector.Direction; import static ch.zhaw.pm2.racetrack.PositionVector.Direction;
@ -14,6 +16,22 @@ import static ch.zhaw.pm2.racetrack.PositionVector.Direction;
public class Game implements GameSpecification { public class Game implements GameSpecification {
public static final int NO_WINNER = -1; public static final int NO_WINNER = -1;
UserInterface userInterface;
public Game(String welcometext) {
userInterface = new UserInterface(welcometext);
}
public void initphase() {
File folder = new File("your/path");
File[] listOfFiles = folder.listFiles();
List<String> tracks = new ArrayList<>();
for(File file : listOfFiles){
tracks.add(file.getName());
}
userInterface.selectOption("Select Track file", tracks);
}
/** /**
* Return the index of the current active car. * Return the index of the current active car.
* Car indexes are zero-based, so the first car is 0, and the last car is getCarCount() - 1. * Car indexes are zero-based, so the first car is 0, and the last car is getCarCount() - 1.