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] ...@@ -6,5 +6,5 @@ Il s'agit d'implémenter une version du jeu "inondation" (voir par exemple [ici]
## Membre du projet ## Membre du projet
- NOM, prénom - EL Gaoual, Zaid e21221636
- NOM, prénom - 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,9 +6,25 @@ import java.util.Iterator; ...@@ -6,9 +6,25 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
public class SquareCell extends AbstractCell{ public class SquareCell extends AbstractCell{
public List<Cell>neighbours;
public SquareCell() {
Color DEFAULT_CELL_COLOR;
List<Cell> neighbours; 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);
}
/** /**
* A cell is placed somewhere on a grid. Its neighbours thus depend on the underlying grid. * A cell is placed somewhere on a grid. Its neighbours thus depend on the underlying grid.
...@@ -16,10 +32,7 @@ public class SquareCell extends AbstractCell{ ...@@ -16,10 +32,7 @@ public class SquareCell extends AbstractCell{
* @return the list of cell that are neighbours of this{@code Cell}. * @return the list of cell that are neighbours of this{@code Cell}.
*/ */
@Override @Override
public List<Cell> getNeighbours() { public List<Cell> getNeighbours() {return this.neighbours;}
return null;
}
/** /**
* Update the list of neighbours of this {@code Cell}. * Update the list of neighbours of this {@code Cell}.
* *
...@@ -28,7 +41,7 @@ public class SquareCell extends AbstractCell{ ...@@ -28,7 +41,7 @@ public class SquareCell extends AbstractCell{
*/ */
@Override @Override
public void setNeighbours(List<Cell> cells) { 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