2 files + 30 − 31 Side-by-side Compare changes Side-by-side Inline Show whitespace changes Files 2 Cell.java +30 −30 Original line number Original line Diff line number Diff line /** /** * {@link Cell} instances represent the cells of <i>The Game of Life</i>. * {@link Cell} instances represent the cells of <i>The Game of Life</i>. */ */ public class Cell { public class Cell { private boolean isAlive; private boolean isAlive; private boolean isRed; public Cell(){ 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. * Determines whether this {@link Cell} is alive or not. * * * @return {@code true} if this {@link Cell} is alive and {@code false} otherwise * @return {@code true} if this {@link Cell} is alive and {@code false} otherwise */ */ public boolean isAlive() { public boolean isAlive() { return this.isAlive; return this.isAlive; } } Loading @@ -24,7 +30,6 @@ public class Cell { * * * @return {@code true} if this {@link Cell} is dead and {@code false} otherwise * @return {@code true} if this {@link Cell} is dead and {@code false} otherwise */ */ public boolean isDead() { public boolean isDead() { return !this.isAlive; return !this.isAlive; } } Loading @@ -32,9 +37,7 @@ public class Cell { /** /** * Sets the state of this {@link Cell} to alive. * Sets the state of this {@link Cell} to alive. * * * @param cellState the new state of this {@link Cell} */ */ public void setAlive() { public void setAlive() { this.isAlive = true; this.isAlive = true; } } Loading @@ -42,18 +45,14 @@ public class Cell { /** /** * Sets the state of this {@link Cell} to dead. * Sets the state of this {@link Cell} to dead. * * * @param cellState the new state of this {@link Cell} */ */ public void setDead() { 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. * Change the state of this {@link Cell} from ALIVE to DEAD or from DEAD to ALIVE. */ */ public void toggleState() { public void toggleState() { if(this.isAlive) if(this.isAlive) this.isAlive = false; this.isAlive = false; Loading @@ -63,7 +62,7 @@ public class Cell { public boolean isAliveInNextState(int numberOfAliveNeighbours) { public boolean isAliveInNextState(int numberOfAliveNeighbours) { if(isAlive()){ if(isAlive()){ if (numberOfAliveNeighbours == 2 || numberOfAliveNeighbours == 3) if ((numberOfAliveNeighbours == 2) || (numberOfAliveNeighbours == 3)) return true; return true; else else return false; return false; Loading @@ -76,3 +75,4 @@ public class Cell { } } } } } } GameOfLife.java +0 −1 Original line number Original line Diff line number Diff line Loading @@ -47,7 +47,6 @@ public class GameOfLife { public Grid getGrid() { public Grid getGrid() { return grid; return grid; } } /** /** * Plays the game. * Plays the game. */ */ Loading
Cell.java +30 −30 Original line number Original line Diff line number Diff line /** /** * {@link Cell} instances represent the cells of <i>The Game of Life</i>. * {@link Cell} instances represent the cells of <i>The Game of Life</i>. */ */ public class Cell { public class Cell { private boolean isAlive; private boolean isAlive; private boolean isRed; public Cell(){ 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. * Determines whether this {@link Cell} is alive or not. * * * @return {@code true} if this {@link Cell} is alive and {@code false} otherwise * @return {@code true} if this {@link Cell} is alive and {@code false} otherwise */ */ public boolean isAlive() { public boolean isAlive() { return this.isAlive; return this.isAlive; } } Loading @@ -24,7 +30,6 @@ public class Cell { * * * @return {@code true} if this {@link Cell} is dead and {@code false} otherwise * @return {@code true} if this {@link Cell} is dead and {@code false} otherwise */ */ public boolean isDead() { public boolean isDead() { return !this.isAlive; return !this.isAlive; } } Loading @@ -32,9 +37,7 @@ public class Cell { /** /** * Sets the state of this {@link Cell} to alive. * Sets the state of this {@link Cell} to alive. * * * @param cellState the new state of this {@link Cell} */ */ public void setAlive() { public void setAlive() { this.isAlive = true; this.isAlive = true; } } Loading @@ -42,18 +45,14 @@ public class Cell { /** /** * Sets the state of this {@link Cell} to dead. * Sets the state of this {@link Cell} to dead. * * * @param cellState the new state of this {@link Cell} */ */ public void setDead() { 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. * Change the state of this {@link Cell} from ALIVE to DEAD or from DEAD to ALIVE. */ */ public void toggleState() { public void toggleState() { if(this.isAlive) if(this.isAlive) this.isAlive = false; this.isAlive = false; Loading @@ -63,7 +62,7 @@ public class Cell { public boolean isAliveInNextState(int numberOfAliveNeighbours) { public boolean isAliveInNextState(int numberOfAliveNeighbours) { if(isAlive()){ if(isAlive()){ if (numberOfAliveNeighbours == 2 || numberOfAliveNeighbours == 3) if ((numberOfAliveNeighbours == 2) || (numberOfAliveNeighbours == 3)) return true; return true; else else return false; return false; Loading @@ -76,3 +75,4 @@ public class Cell { } } } } } }
GameOfLife.java +0 −1 Original line number Original line Diff line number Diff line Loading @@ -47,7 +47,6 @@ public class GameOfLife { public Grid getGrid() { public Grid getGrid() { return grid; return grid; } } /** /** * Plays the game. * Plays the game. */ */ Loading