diff --git a/src/main/java/Application/App.java b/src/main/java/Application/App.java
index 86c4865..db7c8c5 100644
--- a/src/main/java/Application/App.java
+++ b/src/main/java/Application/App.java
@@ -1,13 +1,20 @@
package Application;
+import Game.Game;
import Game.Tictactoe;
+import java.util.ArrayList;
+import java.util.Scanner;
+
public class App {
private boolean isRunning = false;
private Cli cli;
- private Tictactoe ttt;
+ private boolean inMenu = true;
+ private MenuManager menuManager;
+
+ private Game currentGame;
public App(Cli cli) {
this.cli = cli;
@@ -15,23 +22,33 @@ public class App {
}
private void init() {
- ttt = new Tictactoe();
+ menuManager = initMenuManager();
+
+ cli.clearConsole();
cli.getPrintStream().println("Welcome to the Cli Arcade Service!");
cli.getPrintStream().println("Press 'q' at any time to stop the application");
- ttt.print(cli);
+ cli.getPrintStream().println("Select a item by typing the number next to it");
+
+ cli.getPrintStream().print(menuManager.getFormattedMenuList());
}
public void start() {
isRunning = true;
while (isRunning) {
- String input = cli.getScanner().next();
+ String input = cli.getScanner().nextLine();
if (input.equals("q")) {
stop();
return;
} else {
- ttt.update(input);
- cli.clearConsole();
- ttt.print(cli);
+ if (inMenu) {
+ cli.clearConsole();
+ cli.getPrintStream().println("Select a item by typing the number next to it");
+ selectMenuItem(input);
+ } else {
+ cli.clearConsole();
+ currentGame.update(input);
+ currentGame.print(cli);
+ }
}
}
}
@@ -44,4 +61,60 @@ public class App {
public boolean isRunning() {
return isRunning;
}
+
+ public Game getCurrentGame() {
+ return this.currentGame;
+ }
+
+ private MenuManager initMenuManager() {
+ MenuManager mm = new MenuManager();
+ ArrayList