From de293d835e0cefbf9063ea6fae714a77642e3aa1 Mon Sep 17 00:00:00 2001 From: DURIEZ Kilian <kilian.duriez@etu.univ-amu.fr> Date: Sun, 18 Oct 2020 14:30:43 +0200 Subject: [PATCH] Update Cell.java --- Cell.java | 48 ++++++++++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/Cell.java b/Cell.java index 9a0b4bd..c529da1 100644 --- a/Cell.java +++ b/Cell.java @@ -4,11 +4,19 @@ public class Cell { private boolean isAlive; + private String color = "Red"; + + public void setColor(String hisColor) { + color = hisColor; + } + public String getColor() { + return color; + } public Cell(){ - this.isAlive = false; + this.isAlive = false; } - + /** * Determines whether this {@link Cell} is alive or not. * @@ -36,7 +44,7 @@ public class Cell { */ public void setAlive() { - this.isAlive = true; + this.isAlive = true; } /** @@ -46,7 +54,7 @@ public class Cell { */ public void setDead() { - this.isAlive = false; + this.isAlive = false; } @@ -55,24 +63,24 @@ public class Cell { */ public void toggleState() { - if(this.isAlive) - this.isAlive = false; - else - this.isAlive = true; + if(this.isAlive) + this.isAlive = false; + else + this.isAlive = true; } public boolean isAliveInNextState(int numberOfAliveNeighbours) { - if(isAlive()){ - if (numberOfAliveNeighbours == 2 || numberOfAliveNeighbours == 3) - return true; - else - return false; - } - else{ - if (numberOfAliveNeighbours == 3) - return true; - else - return false; - } + if(isAlive()){ + if (numberOfAliveNeighbours == 2 || numberOfAliveNeighbours == 3) + return true; + else + return false; + } + else{ + if (numberOfAliveNeighbours == 3) + return true; + else + return false; + } } } -- GitLab