Skip to content
Snippets Groups Projects
Commit 69ad4c9a authored by MSAYIF Bassem's avatar MSAYIF Bassem
Browse files

Updated Grid Class

-Implemented nextGeneration(), clear() and randomGeneration(Random random) methods.
parent 78e8daf7
No related branches found
No related tags found
No related merge requests found
...@@ -149,7 +149,11 @@ public class Grid implements Iterable<Cell> { ...@@ -149,7 +149,11 @@ 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 (int i = 0; i < this.numberOfRows; i++) {
for (int j = 0; j < this.numberOfColumns; j++) {
cells[i][j].setDead();
}
}
} }
/** /**
...@@ -160,7 +164,13 @@ public class Grid implements Iterable<Cell> { ...@@ -160,7 +164,13 @@ public class Grid implements Iterable<Cell> {
*/ */
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();
}
}
}
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment