From f226f0a96e42d15f453a334a2bc1e548da8c2392 Mon Sep 17 00:00:00 2001
From: b21221851 <mohamed-amine.BEL-KHALIFA@etu.univ-amu.fr>
Date: Wed, 2 Nov 2022 10:13:18 +0100
Subject: [PATCH] task1

---
 app/src/main/java/model/ArrayGrid.java  | 11 ++++++-----
 app/src/main/java/model/SquareCell.java | 13 ++++++++-----
 app/src/main/java/view/MatrixPane.java  |  1 +
 3 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/app/src/main/java/model/ArrayGrid.java b/app/src/main/java/model/ArrayGrid.java
index e71e893..51b0c3e 100644
--- a/app/src/main/java/model/ArrayGrid.java
+++ b/app/src/main/java/model/ArrayGrid.java
@@ -2,12 +2,13 @@ package model;
 
 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.");
-        Cell[][] cells = new Cell[numberOfRows][numberOfColumn];
+        Cell[][] cells = new Cell[numberOfRows][numberOfColumns];
         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();
             }
         }
@@ -19,7 +20,7 @@ public class ArrayGrid implements Grid{
 
     @Override
     public int getNumberOfRows() {
-        return 0;
+        return cells.length;
     }
 
     @Override
diff --git a/app/src/main/java/model/SquareCell.java b/app/src/main/java/model/SquareCell.java
index fd829d0..b0d6883 100644
--- a/app/src/main/java/model/SquareCell.java
+++ b/app/src/main/java/model/SquareCell.java
@@ -7,18 +7,20 @@ import java.util.List;
 
 public class SquareCell extends AbstractCell{
 
-
-    public void squareCell() {
+    List<Cell> neighbours;
+    public SquareCell() {
         Color DEFAULT_CELL_COLOR;
         List<Cell> neighbours;
 
     }
-    public void squareCell(Color color) {
+    public SquareCell(Color 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.setNeighbours(neighbours);
     }
@@ -32,7 +34,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}.
@@ -42,6 +44,7 @@ public class SquareCell extends AbstractCell{
      */
     @Override
     public void setNeighbours(List<Cell> cells) {
+        this.neighbours = cells;
 
     }
 
diff --git a/app/src/main/java/view/MatrixPane.java b/app/src/main/java/view/MatrixPane.java
index f20ed03..2daf662 100644
--- a/app/src/main/java/view/MatrixPane.java
+++ b/app/src/main/java/view/MatrixPane.java
@@ -8,6 +8,7 @@ import javafx.scene.layout.GridPane;
 import javafx.scene.paint.Color;
 import javafx.scene.shape.Rectangle;
 import javafx.util.Duration;
+import model.ArrayGrid;
 import model.Cell;
 import model.GrayGrid;
 import model.Grid;
-- 
GitLab