From 8dad26006ce4a56c4f7253d273e807d5b9ee231c Mon Sep 17 00:00:00 2001 From: romanschenk37 <84532681+romanschenk37@users.noreply.github.com> Date: Fri, 18 Mar 2022 13:34:51 +0100 Subject: [PATCH] change in Main.java --- src/main/java/ch/zhaw/pm2/racetrack/Main.java | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/main/java/ch/zhaw/pm2/racetrack/Main.java b/src/main/java/ch/zhaw/pm2/racetrack/Main.java index 1364d4f..bac1de9 100644 --- a/src/main/java/ch/zhaw/pm2/racetrack/Main.java +++ b/src/main/java/ch/zhaw/pm2/racetrack/Main.java @@ -1,17 +1,28 @@ package ch.zhaw.pm2.racetrack; import java.io.FileNotFoundException; +import java.util.ArrayList; +import java.util.List; public class Main { public static void main(String[] args) throws InvalidTrackFormatException, FileNotFoundException, PositionVectorNotValid { - UserInterface userInterface = new UserInterface("Hello and Welcome"); - Game game = new Game(userInterface); - int winner = 0; - if(game.initPhase()){ - winner = game.gamePhase(); + boolean exit = false; + while (!exit) { + UserInterface userInterface = new UserInterface("Hello and Welcome"); + Game game = new Game(userInterface); + int winner = 0; + if (game.initPhase()) { + winner = game.gamePhase(); + } + List optionsNewGame = new ArrayList<>(); + optionsNewGame.add("exit"); + optionsNewGame.add("new game"); + int selectedOption = userInterface.selectOption("The Winner was Car : " + winner + "\nStart new Game?", optionsNewGame); + if(selectedOption == 0) { + exit = true; + } } - userInterface.printInformation("Winner: " + winner); } }