Skip to content
Snippets Groups Projects
Commit fe0fea9b authored by arthur's avatar arthur
Browse files

implémentation de la méthode boolean calculateNextState

parent f5d3b3f9
No related branches found
No related tags found
No related merge requests found
......@@ -99,7 +99,11 @@ public class Grid implements Iterable<Cell> {
}
private boolean calculateNextState(int rowIndex, int columnIndex, Cell cell) {
return false;
int aliveNeighbours = countAliveNeighbours(rowIndex, columnIndex);
if (cell.isAlive()) {
return aliveNeighbours > 1 && aliveNeighbours < 4;
}
return aliveNeighbours == 3;
}
private int countAliveNeighbours(int rowIndex, int columnIndex) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment