diff --git a/src/Coordinate.java b/src/Coordinate.java index d8ce5e2..675977a 100644 --- a/src/Coordinate.java +++ b/src/Coordinate.java @@ -3,4 +3,11 @@ public class Coordinate { public int x; public int y; + + public Coordinate(int x,int y){ + this.x = x; + this.y = y; + } + + } diff --git a/src/Human.java b/src/Human.java new file mode 100644 index 0000000..6a2e392 --- /dev/null +++ b/src/Human.java @@ -0,0 +1,46 @@ + +import java.io.Console; + +public class Human{ + + + public Coordinate chooseMove(){ + + Console cons = System.console(); + + int x=0,y=0; + boolean pass = false; + + 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); + + System.out.println("Vous avez saisi : "+ x+", "+ y); + + + return new Coordinate(x,y); + } +} \ No newline at end of file