From d2b435110989a0e08c6384482e5e934eb9ad8206 Mon Sep 17 00:00:00 2001 From: r20004714 <andrianinarisaina-cy.RAKOTOARISOA@etu.univ-amu.fr> Date: Thu, 10 Nov 2022 17:11:59 +0100 Subject: [PATCH] =?UTF-8?q?T=C3=A2che=201=20:=20Les=203=20constructeurs=20?= =?UTF-8?q?de=20la=20classe=20SquareCell?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 ++-- app/src/main/java/model/SquareCell.java | 27 ++++++++++++++++++++----- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index f96b6e0..3886e72 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ # Flooding - ## Description du projet Il s'agit d'implémenter une version du jeu "inondation" (voir par exemple [ici]([Flood-it!](https://unixpapa.com/floodit), ainsi que des intelligences artificiels simples pour y jouer. ## Membre du projet - - RAKOTOARISOA, Andrianina + + diff --git a/app/src/main/java/model/SquareCell.java b/app/src/main/java/model/SquareCell.java index 14f51e9..679509b 100644 --- a/app/src/main/java/model/SquareCell.java +++ b/app/src/main/java/model/SquareCell.java @@ -2,19 +2,36 @@ package model; import javafx.scene.paint.Color; +import java.util.ArrayList; import java.util.Iterator; import java.util.List; public class SquareCell extends AbstractCell{ List<Cell> neighbours; + Color color ; + //constructeur 1 : un constructeur sans paramètres qui construit une liste de cellule vide + //de couleur DEFAULT_CELL_COLOR avec une liste de voisins vide + public void SquareCell() { + this.neighbours = new ArrayList<Cell>() ; + color = DEFAULT_CELL_COLOR ; + } + + //Constructeur 2 : un constructeur ayant en paramètre une couleur color + //qui construit une cellule de couleur color et dont les voisins sont vides + public void SquareCell(Color color) { + this.neighbours = new ArrayList<Cell>() ; + this.color = color ; + } + + //Constructeur 3 : un constructeur avec deux paramètres : "Color color" et "ArrayList<Cell> neighbours + //qui consrtuit une cellule de couleur color et dont les cellules voisines sont neighours + public void SquareCell(Color color, List<Cell> neighbours) { + this.neighbours = neighbours ; + this.color = color ; + } - /** - * A cell is placed somewhere on a grid. Its neighbours thus depend on the underlying grid. - * - * @return the list of cell that are neighbours of this{@code Cell}. - */ @Override public List<Cell> getNeighbours() { return null; -- GitLab