Human class
This commit is contained in:
46
src/Human.java
Normal file
46
src/Human.java
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user