Skip to content

Commit

Permalink
Update LightBoard.java
Browse files Browse the repository at this point in the history
  • Loading branch information
chyeung1 authored Apr 30, 2024
1 parent 6fb4136 commit 7985425
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/main/java/LightBoard.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,10 @@ public LightBoard(int numRows, int numCols)
{
/* to be implemented in part (a) */
lights = new boolean[numRows][numCols];
int index = 0;
for(int i = 0; i < numRows; i++){
while(i < numCols){
int probability = (int)Math.random() * 10;
if(probability <= 4) lights[i][index] = true;
else lights[i][index] = false;
index++;
}
index = 0;
}
for(int i = 0; i < numRows; i++)
for(int j = 0; j < numCols; j++)
if(Math.random() <= 0.4)
lights[r][c] = true;
}

/** Evaluates a light in row index row and column index col and returns a status
Expand Down

0 comments on commit 7985425

Please sign in to comment.