public boolean getInput() { this.displayNameList(); // display the list of names // if one player game if (Game.ONE_PLAYER.equals(this.game.gameType)) { System.out.println("\tPlease enter the number of the player."); // get the players name Player player = this.getPlayer(); if (player == null) { return false; } this.game.playerA = player; this.game.playerB.name = "Computer"; } // else two player game else { System.out.println("\tPlease enter the number of the first player."); // get first players name Player player1 = this.getPlayer(); if (player1 == null) { return false; } // get the second players name System.out.println("\tPlease enter the number of the second player."); Player player2 = this.getPlayer(); if (player2 == null) { return false; } this.game.playerA = player1; this.game.playerB = player2; } return true; }
public String selectPlayers(String[] nameList) { String playersName; this.displayNameList(); // display the list of names // if one player game if (Game.ONE_PLAYER.equals(this.game.getGameType())) { System.out.println("\tPlease enter the number of the player."); // get the players name playersName = this.getName(TicTacToe.getNameList()); if (playersName == null) { return Game.QUIT; } this.game.getPlayerA().setName(playersName); this.game.getPlayerB().setName("Computer"); } // else two player game else { System.out.println("\tPlease enter the number of the first player."); // get first players name playersName = this.getName(TicTacToe.getNameList()); if (playersName == null) { return Game.QUIT; } this.game.getPlayerA().setName(playersName); // get the second players name System.out.println("\tPlease enter the number of the second player."); playersName = this.getName(TicTacToe.getNameList()); if (playersName == null) { return Game.QUIT; } this.game.getPlayerB().setName(playersName); } return Game.CONTINUE; }