team02-AngryNerds-projekt1-.../src/main/java/ch/zhaw/pm2/racetrack/Main.java

38 lines
1.3 KiB
Java

package ch.zhaw.pm2.racetrack;
import java.util.ArrayList;
import java.util.List;
public class Main {
public static void main(String[] args) {
UserInterface userInterface = new UserInterface("Hello and Welcome to Racetrack by Team02-\"AngryNerds\"");
while (true) {
Game game = new Game(userInterface);
String winner;
if (game.initPhase()) {
winner = game.gamePhase();
List<String> optionsNewGame = new ArrayList<>();
optionsNewGame.add("exit");
optionsNewGame.add("new game");
String winnerText;
if (winner == null) {
winnerText = "There was no winner.";
} else {
winnerText = "The Winner was Car " + winner;
}
int selectedOption = userInterface.selectOption(winnerText + "\nStart new Game?", optionsNewGame);
if (selectedOption == 0) {
userInterface.quit("Thank you and goodbye\npress enter to close the application.");
break;
}
} else {
userInterface.quit("The initialisation of the game failed. Press enter to close the application.");
break;
}
}
}
}