Skip to content
Snippets Groups Projects
Commit 665d125f authored by EL GAOUAL Zaid's avatar EL GAOUAL Zaid
Browse files

Squared Cell & ArrayGrid

parent f1b2f519
No related branches found
No related tags found
No related merge requests found
Pipeline #10237 failed
......@@ -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
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;
}
}
......@@ -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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment