This commit is contained in:
Aubin DORIVAL
2025-03-24 10:27:09 +01:00
2 changed files with 53 additions and 0 deletions

View File

@@ -3,4 +3,11 @@
public class Coordinate { public class Coordinate {
public int x; public int x;
public int y; public int y;
public Coordinate(int x,int y){
this.x = x;
this.y = y;
}
} }

46
src/Human.java Normal file
View File

@@ -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);
}
}