From 4ebe8cb1edbf1f72c28261356a5f7eb300b78c39 Mon Sep 17 00:00:00 2001 From: romanschenk37 <84532681+romanschenk37@users.noreply.github.com> Date: Thu, 10 Mar 2022 15:18:08 +0100 Subject: [PATCH] created Method initphase in Game.java --- src/main/java/ch/zhaw/pm2/racetrack/Game.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/main/java/ch/zhaw/pm2/racetrack/Game.java b/src/main/java/ch/zhaw/pm2/racetrack/Game.java index 27609ca..151a4a6 100644 --- a/src/main/java/ch/zhaw/pm2/racetrack/Game.java +++ b/src/main/java/ch/zhaw/pm2/racetrack/Game.java @@ -2,6 +2,8 @@ package ch.zhaw.pm2.racetrack; import ch.zhaw.pm2.racetrack.given.GameSpecification; +import java.io.File; +import java.util.ArrayList; import java.util.List; 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 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 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. * Car indexes are zero-based, so the first car is 0, and the last car is getCarCount() - 1.