diff --git a/tp3/Grid.java b/tp3/Grid.java index 22ca2a69e27dcb0155d5e8cf0db7906122a97d52..781db12925b80a64c74d266568164d33386bae02 100644 --- a/tp3/Grid.java +++ b/tp3/Grid.java @@ -149,7 +149,11 @@ public class Grid implements Iterable<Cell> { * Sets all {@link Cell}s in this {@code Grid} as dead. */ void clear() { - + for (int i = 0; i < this.numberOfRows; i++) { + for (int j = 0; j < this.numberOfColumns; j++) { + cells[i][j].setDead(); + } + } } /** @@ -158,9 +162,15 @@ public class Grid implements Iterable<Cell> { * @param random {@link Random} instance used to decide if each {@link Cell} is alive or dead * @throws NullPointerException if {@code random} is {@code null} */ - - void randomGeneration(Random random) { + void randomGeneration(Random random) { + for (int i = 0; i < getNumberOfRows(); i++) { + for (int j = 0; j < getNumberOfColumns(); j++) { + if(random.nextBoolean()){ + cells[i][j].setAlive(); + } + } + } } }