Skip to content
Snippets Groups Projects
Commit f226f0a9 authored by BEL KHALIFA Mohamed amine's avatar BEL KHALIFA Mohamed amine
Browse files

task1

parent 27665821
No related branches found
No related tags found
No related merge requests found
...@@ -2,12 +2,13 @@ package model; ...@@ -2,12 +2,13 @@ package model;
public class ArrayGrid implements Grid{ public class ArrayGrid implements Grid{
public void arrayGrid(int numberOfRows, int numberOfColumn) {
if(numberOfRows <= 0 || numberOfColumn <= 0) 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."); throw new IllegalArgumentException("Le nombre de lignes ou de colonnes ne peut pas être nul ou négatif.");
Cell[][] cells = new Cell[numberOfRows][numberOfColumn]; Cell[][] cells = new Cell[numberOfRows][numberOfColumns];
for(int i = 0; i < numberOfRows; i++) { for(int i = 0; i < numberOfRows; i++) {
for(int j = 0; j < numberOfColumn; j++) { for(int j = 0; j < numberOfColumns; j++) {
cells[i][j] = new SquareCell(); cells[i][j] = new SquareCell();
} }
} }
...@@ -19,7 +20,7 @@ public class ArrayGrid implements Grid{ ...@@ -19,7 +20,7 @@ public class ArrayGrid implements Grid{
@Override @Override
public int getNumberOfRows() { public int getNumberOfRows() {
return 0; return cells.length;
} }
@Override @Override
......
...@@ -7,18 +7,20 @@ import java.util.List; ...@@ -7,18 +7,20 @@ import java.util.List;
public class SquareCell extends AbstractCell{ public class SquareCell extends AbstractCell{
List<Cell> neighbours;
public void squareCell() { public SquareCell() {
Color DEFAULT_CELL_COLOR; Color DEFAULT_CELL_COLOR;
List<Cell> neighbours; List<Cell> neighbours;
} }
public void squareCell(Color color) { public SquareCell(Color color) {
this.setColor(color); this.setColor(color);
List<Cell> neighbours;
} }
public void squareCell(Color color, List<Cell> neighbours) { public SquareCell(Color color, List<Cell> neighbours) {
this.setColor(color); this.setColor(color);
this.setNeighbours(neighbours); this.setNeighbours(neighbours);
} }
...@@ -32,7 +34,7 @@ public class SquareCell extends AbstractCell{ ...@@ -32,7 +34,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() {return null;} public List<Cell> getNeighbours() {return this.neighbours;}
/** /**
* Update the list of neighbours of this {@code Cell}. * Update the list of neighbours of this {@code Cell}.
...@@ -42,6 +44,7 @@ public class SquareCell extends AbstractCell{ ...@@ -42,6 +44,7 @@ public class SquareCell extends AbstractCell{
*/ */
@Override @Override
public void setNeighbours(List<Cell> cells) { public void setNeighbours(List<Cell> cells) {
this.neighbours = cells;
} }
......
...@@ -8,6 +8,7 @@ import javafx.scene.layout.GridPane; ...@@ -8,6 +8,7 @@ import javafx.scene.layout.GridPane;
import javafx.scene.paint.Color; import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle; import javafx.scene.shape.Rectangle;
import javafx.util.Duration; import javafx.util.Duration;
import model.ArrayGrid;
import model.Cell; import model.Cell;
import model.GrayGrid; import model.GrayGrid;
import model.Grid; import model.Grid;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment