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

  1. package Application;
  2. import Game.Tictactoe;
  3. public class App {
  4. private boolean isRunning = false;
  5. private Cli cli;
  6. private Tictactoe ttt;
  7. public App(Cli cli) {
  8. this.cli = cli;
  9. init();
  10. }
  11. private void init() {
  12. ttt = new Tictactoe();
  13. cli.getPrintStream().println("Welcome to the Cli Arcade Service!");
  14. cli.getPrintStream().println("Press 'q' at any time to stop the application");
  15. ttt.print(cli);
  16. }
  17. public void start() {
  18. isRunning = true;
  19. while (isRunning) {
  20. String input = cli.getScanner().next();
  21. if (input.equals("q")) {
  22. stop();
  23. return;
  24. } else {
  25. ttt.update(input);
  26. ttt.print(cli);
  27. }
  28. }
  29. }
  30. public void stop() {
  31. isRunning = false;
  32. cli.getPrintStream().println("Stopping application...");
  33. }
  34. public boolean isRunning() {
  35. return isRunning;
  36. }
  37. }