From 04a2093b370e86605c627f8e40cc4aa0beb72721 Mon Sep 17 00:00:00 2001 From: h18008908 <mohamed.hamadache@etu.univ-amu.fr> Date: Sun, 1 Nov 2020 17:24:01 +0100 Subject: [PATCH] ok --- Cell.java | 62 +++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 22 deletions(-) diff --git a/Cell.java b/Cell.java index 9a0b4bd..46a38dc 100644 --- a/Cell.java +++ b/Cell.java @@ -4,11 +4,13 @@ public class Cell { private boolean isAlive; + private boolean isBlue; - public Cell(){ - this.isAlive = false; + public Cell() { + this.isAlive = false; + this.isBlue = false; } - + /** * Determines whether this {@link Cell} is alive or not. * @@ -19,6 +21,10 @@ public class Cell { return this.isAlive; } + public boolean isBlue() { + return this.isBlue; + } + /** * Determines whether this {@link Cell} is dead or not. * @@ -29,6 +35,10 @@ public class Cell { return !this.isAlive; } + public boolean isRed() { + return !this.isBlue; + } + /** * Sets the state of this {@link Cell} to alive. * @@ -36,9 +46,14 @@ public class Cell { */ public void setAlive() { - this.isAlive = true; + this.isAlive = true; } + public void setBlue() { + this.isBlue = true; + } + + /** * Sets the state of this {@link Cell} to dead. * @@ -46,7 +61,11 @@ public class Cell { */ public void setDead() { - this.isAlive = false; + this.isAlive = false; + } + + public void setRed() { + this.isBlue = false; } @@ -55,24 +74,23 @@ 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; + } } -} +} \ No newline at end of file -- GitLab