diff --git a/Cell.java b/Cell.java index 4ace9225317aa37f0c574e16be238c83d0d0ca64..d91aeaec40b714197e440d4eb3864ab2f8d5b233 100644 --- a/Cell.java +++ b/Cell.java @@ -5,7 +5,7 @@ public class Cell { private boolean isAlive; - private String color = "Blue"; + private String color = "Red"; public Cell(){ this.isAlive = false; diff --git a/Grid.java b/Grid.java index e8a18d2c90be38b55ed63e13ed75523305606d44..680686040da251d59548bd73a30e994ce4228abd 100644 --- a/Grid.java +++ b/Grid.java @@ -120,9 +120,11 @@ public class Grid implements Iterable<Cell> { private boolean calculateNextState(int rowIndex, int columnIndex, Cell cell) { boolean Nextstate = cell.isAliveInNextState(this.countAliveNeighbours(rowIndex, columnIndex)); - if (Nextstate) { - cell.setColor(this.countColorNeighbours(rowIndex, columnIndex)); - } + if (Nextstate) { + if (this.countAliveNeighbours(rowIndex, columnIndex) != 2) { + cell.setColor(this.countColorNeighbours(rowIndex, columnIndex)); + } + } return Nextstate; } @@ -152,13 +154,14 @@ public class Grid implements Iterable<Cell> { } } - if (Red>=Blue) { + if (Red>Blue) { CounterColorCell="Red"; } else { CounterColorCell="Blue"; } + return CounterColorCell; }