public int pickABox(BusinessLogic newGame) { int input = 0; boolean validInput = false; while (!validInput) { System.out.println("Box number: "); String inputString = scan.next(); input = inputString.charAt(0) - 48; if (newGame.isValidInput(input)) { validInput = true; } else { System.out.println("That is not a valid option"); } } return input; }
public void playGame(Player player1, Player player2) { BusinessLogic newGame = new BusinessLogic(player1, player2); boolean gameOver = false; int turnNum = 0; while (!gameOver) { clear(); System.out.println(newGame.getGrid()); if (turnNum % 2 == 0) { boxMessage(player1); } else { boxMessage(player2); } newGame.markNode(pickABox(newGame), turnNum); if (newGame.bingo()) { clear(); System.out.println(newGame.getGrid()); if (turnNum % 2 == 0) { winMessage(player1, player2); } else { winMessage(player2, player1); } gameOver = true; } if (turnNum == 8) { clear(); System.out.println(newGame.getGrid()); System.out.println("You are equally bright! ...or stupid."); gameOver = true; } turnNum++; } }