import java.io.Console; public class Human extends Player{ //------------------Constructors-------------------------- /** * The constructor of the Human. * @param name The name of the player. * @param color The color of the player. */ public Human(String name,Color color){ super(name,color); } /** * This class is an extends of the class Player, this allows the player to choose his move. */ //------------------Methods-------------------------- /** * Return the coordinate of the move played by the player. * @param board The actual Gomoku board. * @return The cell of the move played. */ public GomokuCell chooseMove(GomokuBoard board){ Console cons = System.console(); int x=0,y=0; boolean pass = false; do{ do{ try { System.out.println("Veuillez saisir le X"); x = Integer.parseInt( cons.readLine()); pass=true; } catch (NumberFormatException e) { System.out.println("Ce n'est pas un nombre !"); pass=false; } } while(!pass); do{ try { System.out.println("Veuillez saisir le Y"); y = Integer.parseInt( cons.readLine()); pass=true; } catch (NumberFormatException e) { System.out.println("Ce n'est pas un nombre !"); pass=false; } } while(!pass); pass =board.get(x,y).isPlayable(); if(!pass) { System.out.println("Cette case n'est pas jouable !"); } } while(!pass); System.out.println("Vous avez saisi : "+ x+", "+ y); return board.get(x,y); } }