From 665d125ff11e0a7e036610a6a9274638dd49c2d9 Mon Sep 17 00:00:00 2001
From: e21221636 <zaid.EL-GAOUAL@etu.univ-amu.fr>
Date: Wed, 2 Nov 2022 10:17:19 +0100
Subject: [PATCH] Squared Cell & ArrayGrid

---
 README.md                               |  4 ++--
 app/src/main/java/model/ArrayGrid.java  | 30 +++++++++++++++++++++++++
 app/src/main/java/model/SquareCell.java | 25 ++++++++++++++++-----
 3 files changed, 51 insertions(+), 8 deletions(-)
 create mode 100644 app/src/main/java/model/ArrayGrid.java

diff --git a/README.md b/README.md
index 7bcec58..cf8fff7 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 0000000..998b60b
--- /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 14f51e9..c48622c 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;
     }
 
 
-- 
GitLab