From 57a5d199a603b799d5e524edec8bd9e207edeac9 Mon Sep 17 00:00:00 2001 From: romanschenk37 <84532681+romanschenk37@users.noreply.github.com> Date: Thu, 10 Mar 2022 15:29:04 +0100 Subject: [PATCH] changes in Method initphase --- src/main/java/ch/zhaw/pm2/racetrack/Game.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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); } /**