diff --git a/README.md b/README.md index b6ad266358f7b5f3012380e0f6fd28fe9b4df250..fb702c0c1416213b07af3ebf3013b06f0c61c3c6 100644 --- a/README.md +++ b/README.md @@ -6,5 +6,5 @@ Il s'agit d'implémenter une version du jeu "inondation" (voir par exemple [ici] ## Membre du projet -- EL GHAOUTI, Aymane +- EL GHAOUTI , Aymane - NOM, prénom diff --git a/app/src/main/java/model/SquareCell.java b/app/src/main/java/model/SquareCell.java index 14f51e9fb9c85ba7fc0c6069ae676556a200bbbe..35f1b095d8eb861652a45589d32b8d9ffce1dba0 100644 --- a/app/src/main/java/model/SquareCell.java +++ b/app/src/main/java/model/SquareCell.java @@ -2,6 +2,8 @@ package model; import javafx.scene.paint.Color; +import java.util.ArrayList; +import java.util.Collections; import java.util.Iterator; import java.util.List; @@ -9,6 +11,21 @@ public class SquareCell extends AbstractCell{ List<Cell> neighbours; + public SquareCell(){ + setColor(AbstractCell.DEFAULT_CELL_COLOR); + setNeighbours(null); + + } + public SquareCell( Color color){ + setColor(color); + setNeighbours(null); + + } + public SquareCell(Color color,List<Cell>neighbours){ + SquareCell Cell=new SquareCell(color); + setNeighbours( neighbours); + } + /** * A cell is placed somewhere on a grid. Its neighbours thus depend on the underlying grid. @@ -17,7 +34,7 @@ public class SquareCell extends AbstractCell{ */ @Override public List<Cell> getNeighbours() { - return null; + return neighbours; } /** @@ -28,8 +45,19 @@ public class SquareCell extends AbstractCell{ */ @Override public void setNeighbours(List<Cell> cells) { + if (cells==null){ + neighbours=new ArrayList<>(); + } + else { + + neighbours=new ArrayList<>(); + for (Cell value:cells) + { + neighbours.add(value); + } + } } -} +} \ No newline at end of file