From 59e45a729769f41e0a3c05b2c43a34ebdc5c6458 Mon Sep 17 00:00:00 2001
From: Hatim Saidi <hatim.saidi@etu.univ-amu.fr>
Date: Wed, 9 Nov 2022 22:21:09 +0100
Subject: [PATCH] test

---
 app/src/main/java/model/ArrayGrid.java  | 28 +++++++++++++++++++------
 app/src/main/java/model/SquareCell.java | 10 +++++----
 2 files changed, 28 insertions(+), 10 deletions(-)

diff --git a/app/src/main/java/model/ArrayGrid.java b/app/src/main/java/model/ArrayGrid.java
index 7cfca47..e4b6bdc 100644
--- a/app/src/main/java/model/ArrayGrid.java
+++ b/app/src/main/java/model/ArrayGrid.java
@@ -7,15 +7,31 @@ public class ArrayGrid implements Grid{
     private final int numberOfColumns ;
 
 
-    public ArrayGrid(int numberOfRows,int numberOfColumns){
+    public ArrayGrid(int numberOfRows,int numberOfColumns) {
         this.numberOfRows = numberOfRows;
         this.numberOfColumns = numberOfColumns;
-        this.cells[numberOfRows][numberOfColumns]=new SquareCell();
-        try {
-             System.out.println(numberOfColumns<0 || numberOfRows<0);
-        }catch (IllegalArgumentException e){
-            System.out.println(e);
+        if (numberOfColumns > 0 || numberOfRows > 0) {
+            for (int j = 0; j < this.numberOfColumns; j++) {
+                for (int i = 0; i < this.numberOfRows; i++) {
+                    cells[numberOfRows][numberOfColumns] = new SquareCell();
+                }
+            }
         }
+        else {
+            throw  new IllegalArgumentException() ;
+        }
+    }
+
+    public Cell getCell(int row, int column) {
+        return this.cells[row][column];
     }
 
+    public int getNumberOfRows(){
+        return this.numberOfRows;
+    }
+    public int getNumberOfColumns(){
+        return  this.numberOfColumns;
+    }
+
+
 }
diff --git a/app/src/main/java/model/SquareCell.java b/app/src/main/java/model/SquareCell.java
index dd412e1..bddd8bd 100644
--- a/app/src/main/java/model/SquareCell.java
+++ b/app/src/main/java/model/SquareCell.java
@@ -11,17 +11,19 @@ public class SquareCell extends AbstractCell {
 
     List<Cell> neighbours;
 
-
     public SquareCell() {
-        AbstractCell cell = new SquareCell();
+        Color cell = DEFAULT_CELL_COLOR;
+        this.neighbours = new ArrayList<>();
     }
 
     public SquareCell(Color color){
-        AbstractCell cell = new SquareCell(color);
+       Color cell = color;
+       this.neighbours = new ArrayList<>();
     }
 
     public SquareCell(Color color,List<Cell>neighbours){
-        AbstractCell cell = new SquareCell(color,neighbours);
+        Color cell = color;
+        this.neighbours = neighbours;
     }
 
     @Override
-- 
GitLab