You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1006 B
46 lines
1006 B
package Application;
|
|
|
|
import Game.Tictactoe;
|
|
|
|
public class App {
|
|
|
|
private boolean isRunning = false;
|
|
private Cli cli;
|
|
|
|
private Tictactoe ttt;
|
|
|
|
public App(Cli cli) {
|
|
this.cli = cli;
|
|
init();
|
|
}
|
|
|
|
private void init() {
|
|
ttt = new Tictactoe();
|
|
cli.getPrintStream().println("Welcome to the Cli Arcade Service!");
|
|
cli.getPrintStream().println("Press 'q' at any time to stop the application");
|
|
ttt.print(cli);
|
|
}
|
|
|
|
public void start() {
|
|
isRunning = true;
|
|
while (isRunning) {
|
|
String input = cli.getScanner().next();
|
|
if (input.equals("q")) {
|
|
stop();
|
|
return;
|
|
} else {
|
|
ttt.update(input);
|
|
ttt.print(cli);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void stop() {
|
|
isRunning = false;
|
|
cli.getPrintStream().println("Stopping application...");
|
|
}
|
|
|
|
public boolean isRunning() {
|
|
return isRunning;
|
|
}
|
|
}
|