1. package Game;
  2.  
  3. import utils.ConsoleUtils;
  4.  
  5. public class GameController {
  6.     private static GameLogic gameLogic;
  7.    
  8.     private GameController() {
  9.         gameLogic = new GameLogic();
  10.         Menu.welcomeMessage();
  11.         Menu.showCommands();
  12.     }
  13.    
  14.     public static void main(String[] args) {
  15.         boolean hasGameStarted = false;
  16.        
  17.         // Lazy hack, clean this up
  18.         while( !hasGameStarted || gameLogic.isGameOver() ) {
  19.             for ( String arg : args ) {
  20.                 hasGameStarted = arg.matches( Menu.startGamePattern );
  21.             }
  22.            
  23.             String input = ConsoleUtils.getInput("Enter a command");
  24.             hasGameStarted = input.matches( Menu.startGamePattern );
  25.            
  26.             if ( input.matches( Menu.quitGamePattern ) ) {
  27.                 gameLogic.endGame();
  28.             } else if ( input.matches( Menu.reportGamePattern ) ) {
  29.                 System.out.println("Game hasn't started yet");
  30.             } else {
  31.                 System.out.println("Invalid command!\n");
  32.             }
  33.         }
  34.        
  35.         gameLogic.start(); //Player sets the hidden number
  36.        
  37.         while( !gameLogic.isGameOver() ) {
  38.             String input = ConsoleUtils.getInput("Enter a command");
  39.            
  40.             if ( input.matches( Menu.quitGamePattern ) ) {
  41.                 gameLogic.endGame();
  42.             } else if ( input.matches( Menu.reportGamePattern ) ) {
  43.                 System.out.println( String.format("You made %d guesses so far.", gameLogic.getAttempts()));
  44.             } else if( input.matches( Menu.makeGuessPattern )) {
  45.                 gameLogic.makeGuess();
  46.             } else {
  47.                 System.out.println("Invalid command!\n");
  48.             }
  49.         }
  50.     }
  51. }