Skip to content

Commit

Permalink
Update LightBoard.java
Browse files Browse the repository at this point in the history
  • Loading branch information
chloehuang16 authored Apr 30, 2024
1 parent 57ea049 commit 0c7f914
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion src/main/java/LightBoard.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ public class LightBoard
public LightBoard(int numRows, int numCols)
{
/* to be implemented in part (a) */
this.lights = new boolean[numRows][numCols];
for (int i = 0; i<this.lights.length;i++){
for (int j = 0; j<this.lights[i].length;j++){
if (Math.random<0.4){
this.lights[i][j] = true;
}
else{
this.lights[i][j] = false;
}
}
}

}

Expand All @@ -21,7 +32,21 @@ public LightBoard(int numRows, int numCols)
public boolean evaluateLight(int row, int col)
{
/* to be implemented in part (b) */

int numOn = 0;
if(lights[row][col] == true){
for (int i = 0; i<lights.length;i++){
if (lights[i][col] == true){
numOn;
}
}
if (numOn % 2 == 0){
return false;
}
else{
return true;
}
}


}
public boolean[][] getLights()
Expand Down

0 comments on commit 0c7f914

Please sign in to comment.