Merge branch 'master' of gitlab.isima.fr:audorival/gomoku

This commit is contained in:
Aubin DORIVAL
2025-03-24 11:02:21 +01:00
2 changed files with 36 additions and 22 deletions

View File

@@ -1,10 +1,11 @@
import java.io.Console; import java.io.Console;
import java.util.List;
public class Human{ public class Human{
public Coordinate chooseMove(){ public Coordinate chooseMove(GomokuBoard board){
Console cons = System.console(); Console cons = System.console();
@@ -12,28 +13,38 @@ public class Human{
boolean pass = false; boolean pass = false;
do{ do{
try {
System.out.println("Veuillez saisir le X");
x = Integer.parseInt( cons.readLine());
pass=true;
} catch (NumberFormatException e) { do{
System.out.println("Ce n'est pas un nombre !"); try {
pass=false; 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);
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);
do{ pass =board.getCell(x,y).isPlayable();
try { if(!pass)
System.out.println("Veuillez saisir le Y"); {
y = Integer.parseInt( cons.readLine()); System.out.println("Cette case n'est pas jouable !");
pass=true;
} catch (NumberFormatException e) {
System.out.println("Ce n'est pas un nombre !");
pass=false;
} }
} }
while(!pass); while(!pass);

View File

@@ -1,4 +1,7 @@
import java.util.List;
abstract class Player{ abstract class Player{
private String name; private String name;
@@ -7,5 +10,5 @@ abstract class Player{
return name; return name;
} }
public abstract Coordinate chooseMove(); public abstract Coordinate chooseMove(GomokuBoard Board);
} }