diff --git a/src/main/java/ch/zhaw/pm2/racetrack/Game.java b/src/main/java/ch/zhaw/pm2/racetrack/Game.java index 151a4a6..86a67c4 100644 --- a/src/main/java/ch/zhaw/pm2/racetrack/Game.java +++ b/src/main/java/ch/zhaw/pm2/racetrack/Game.java @@ -3,6 +3,7 @@ package ch.zhaw.pm2.racetrack; import ch.zhaw.pm2.racetrack.given.GameSpecification; import java.io.File; +import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.List; @@ -15,6 +16,7 @@ import static ch.zhaw.pm2.racetrack.PositionVector.Direction; */ public class Game implements GameSpecification { public static final int NO_WINNER = -1; + private Track track; UserInterface userInterface; @@ -22,14 +24,15 @@ public class Game implements GameSpecification { userInterface = new UserInterface(welcometext); } - public void initphase() { + public void initphase() throws InvalidTrackFormatException, FileNotFoundException { File folder = new File("your/path"); File[] listOfFiles = folder.listFiles(); List tracks = new ArrayList<>(); for(File file : listOfFiles){ tracks.add(file.getName()); } - userInterface.selectOption("Select Track file", tracks); + File selectedTrack = listOfFiles[userInterface.selectOption("Select Track file", tracks)]; + track = new Track(selectedTrack); } /**