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; }
public SelectPlayersView(Game game) { this.game = game; playerNames = TicTacToe.getNameList(); }