changes in Method initphase

This commit is contained in:
romanschenk37 2022-03-10 15:29:04 +01:00
parent 4ebe8cb1ed
commit 57a5d199a6
1 changed files with 5 additions and 2 deletions

View File

@ -3,6 +3,7 @@ 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.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -15,6 +16,7 @@ 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;
private Track track;
UserInterface userInterface; UserInterface userInterface;
@ -22,14 +24,15 @@ public class Game implements GameSpecification {
userInterface = new UserInterface(welcometext); userInterface = new UserInterface(welcometext);
} }
public void initphase() { public void initphase() throws InvalidTrackFormatException, FileNotFoundException {
File folder = new File("your/path"); File folder = new File("your/path");
File[] listOfFiles = folder.listFiles(); File[] listOfFiles = folder.listFiles();
List<String> tracks = new ArrayList<>(); List<String> tracks = new ArrayList<>();
for(File file : listOfFiles){ for(File file : listOfFiles){
tracks.add(file.getName()); tracks.add(file.getName());
} }
userInterface.selectOption("Select Track file", tracks); File selectedTrack = listOfFiles[userInterface.selectOption("Select Track file", tracks)];
track = new Track(selectedTrack);
} }
/** /**