genCells no finished

This commit is contained in:
Aubin DORIVAL
2025-03-31 11:03:40 +02:00
parent 0140f1ed93
commit f7825248bc
3 changed files with 98 additions and 17 deletions

View File

@@ -1,6 +1,8 @@
import java.util.EnumMap;
import java.util.concurrent.ExecutionException;
import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;
/**
* This class is cell of the board of the Gomoku game.
*/
@@ -56,8 +58,6 @@ public class GomokuCell{
* @throws IllegalStateException If the cell is not playable.
*/
public void setState(Color c){
if (!this.isPlayable())
throw new IllegalStateException("This cell is not playable !" + this.toString());
this.state = c;
}
@@ -104,12 +104,22 @@ public class GomokuCell{
this.neighbour.put(car, cell);
}
//------------------Statics--------------------------
public static void link(GomokuCell c1, GomokuCell c2, Cardinal c1Toc2){
if (c1 == null || c2 == null) return ;
List<Cardinal> cardinals = Arrays.asList(Cardinal.values());
c1.linkCell(c1Toc2, c2);
c2.linkCell(cardinals.get((cardinals.indexOf(c1Toc2) + 4) % 8), c1);
}
//------------------Overides--------------------------
@Override
public String toString() {
switch (this.getSate()) {
case Color.NIL:
return " ";
return ".";
case Color.BLACK:
return "X";
case Color.WHITE: