From ad5e7fc5ad4a00c330bb16b493d6bcbe8413adf5 Mon Sep 17 00:00:00 2001 From: AZZOUG Lydia <lydia.azzoug@etu.univ-amu.fr> Date: Sun, 18 Oct 2020 21:33:47 +0200 Subject: [PATCH] Replace Cell.java --- Cell.java | 60 +++++++++++++++++++++++++++---------------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/Cell.java b/Cell.java index 9a0b4bd..c740060 100644 --- a/Cell.java +++ b/Cell.java @@ -1,20 +1,26 @@ /** * {@link Cell} instances represent the cells of <i>The Game of Life</i>. */ - public class Cell { private boolean isAlive; - + private boolean isRed; public Cell(){ - this.isAlive = false; + this.isAlive = false; + } + + public void setisRed(boolean bool){ + this.isRed = bool; } - + + public boolean isRed(){ + return this.isRed; + } + /** * Determines whether this {@link Cell} is alive or not. * * @return {@code true} if this {@link Cell} is alive and {@code false} otherwise */ - public boolean isAlive() { return this.isAlive; } @@ -24,7 +30,6 @@ public class Cell { * * @return {@code true} if this {@link Cell} is dead and {@code false} otherwise */ - public boolean isDead() { return !this.isAlive; } @@ -32,47 +37,42 @@ public class Cell { /** * Sets the state of this {@link Cell} to alive. * - * @param cellState the new state of this {@link Cell} */ - public void setAlive() { - this.isAlive = true; + this.isAlive = true; } /** * Sets the state of this {@link Cell} to dead. * - * @param cellState the new state of this {@link Cell} */ - public void setDead() { - this.isAlive = false; + this.isAlive = false; } - /** * Change the state of this {@link Cell} from ALIVE to DEAD or from DEAD to ALIVE. */ - 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