diff --git a/README.md b/README.md index 7bcec58d58606f656ddbdab538783ab330766490..cf8fff7c1577db70c1bbbade91632e6169b1a47b 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 -- NOM, prénom -- NOM, prénom +- EL Gaoual, Zaid e21221636 +- BELKHALIFA, Mohamed Amine diff --git a/app/src/main/java/model/ArrayGrid.java b/app/src/main/java/model/ArrayGrid.java new file mode 100644 index 0000000000000000000000000000000000000000..998b60bfa753b73544f869add91f4703945448c4 --- /dev/null +++ b/app/src/main/java/model/ArrayGrid.java @@ -0,0 +1,30 @@ +package model; + +public class ArrayGrid implements Grid{ + public Cell[][] cells; + + public void arrayGrid(int numberOfRows, int numberOfColumns) { + if(numberOfRows <= 0 || numberOfColumns <= 0) + throw new IllegalArgumentException("Le nombre de lignes ou de colonnes ne peut pas être nul ou négatif."); + Cell[][] cells = new Cell[numberOfRows][numberOfColumns]; + for(Cell[] column : cells ) { + for(Cell cell : column) { + cell = new SquareCell(); + } + } + } + @Override + public Cell getCell(int row, int column) { + return cells[row][column]; + } + + @Override + public int getNumberOfRows() { + return cells.length; + } + + @Override + public int getNumberOfColumns() { + return cells[0].length; + } +} diff --git a/app/src/main/java/model/SquareCell.java b/app/src/main/java/model/SquareCell.java index 14f51e9fb9c85ba7fc0c6069ae676556a200bbbe..c48622c4c0e966fc406a478502bd8270040bbee4 100644 --- a/app/src/main/java/model/SquareCell.java +++ b/app/src/main/java/model/SquareCell.java @@ -6,8 +6,24 @@ import java.util.Iterator; import java.util.List; public class SquareCell extends AbstractCell{ + public List<Cell>neighbours; + + public SquareCell() { + Color DEFAULT_CELL_COLOR; + List<Cell> neighbours; + + } + public SquareCell(Color color) { + this.setColor(color); + List<Cell> neighbours; + } + + public SquareCell(Color color, List<Cell> neighbours) { + this.setColor(color); + this.setNeighbours(neighbours); + } + - List<Cell> neighbours; /** @@ -16,10 +32,7 @@ public class SquareCell extends AbstractCell{ * @return the list of cell that are neighbours of this{@code Cell}. */ @Override - public List<Cell> getNeighbours() { - return null; - } - + public List<Cell> getNeighbours() {return this.neighbours;} /** * Update the list of neighbours of this {@code Cell}. * @@ -28,7 +41,7 @@ public class SquareCell extends AbstractCell{ */ @Override public void setNeighbours(List<Cell> cells) { - + this.neighbours=cells; }