Skip to content
Snippets Groups Projects
Commit 25f19abb authored by Mattéo's avatar Mattéo
Browse files

Everything done but unsure

parent a34eeb44
No related branches found
No related tags found
No related merge requests found
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavacSettings">
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
<module name="TP3" options="--add-exports jdk.compiler/com.sun.tools.doclint=ALL-UNNAMED" />
</option>
</component>
</project>
\ No newline at end of file
...@@ -139,10 +139,14 @@ public class Grid implements Iterable<Cell> { ...@@ -139,10 +139,14 @@ public class Grid implements Iterable<Cell> {
} }
private void goToNextState(boolean[][] nextState) { private void goToNextState(boolean[][] nextState) {
Iterator<Cell> iterator = iterator(); for (Cell cell : this) {
while (iterator.hasNext()) { for (int i = 0; i == numberOfRows - 1; i++) {
Cell cell = iterator.next(); for (int j = 0; j == numberOfColumns - 1; j++) {
cell.isAlive() = nextState[][]; if (nextState[i][j]) {
cell.setAlive();
} else cell.setDead();
}
}
} }
} }
...@@ -150,6 +154,9 @@ public class Grid implements Iterable<Cell> { ...@@ -150,6 +154,9 @@ public class Grid implements Iterable<Cell> {
* Sets all {@link Cell}s in this {@code Grid} as dead. * Sets all {@link Cell}s in this {@code Grid} as dead.
*/ */
void clear() { void clear() {
for (Cell cell : this) {
cell.setDead();
}
} }
/** /**
...@@ -160,6 +167,10 @@ public class Grid implements Iterable<Cell> { ...@@ -160,6 +167,10 @@ public class Grid implements Iterable<Cell> {
*/ */
void randomGeneration(Random random) { void randomGeneration(Random random) {
for (Cell cell : this) {
if (random.nextBoolean()) {cell.setAlive();}
else cell.setDead();
}
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment