diff --git a/src/main/java/LightBoard.java b/src/main/java/LightBoard.java index b725d72..c6de415 100644 --- a/src/main/java/LightBoard.java +++ b/src/main/java/LightBoard.java @@ -12,11 +12,12 @@ public LightBoard(int numRows, int numCols) { /* to be implemented in part (a) */ lights = new boolean[numRows][numCols]; - for(int r = 0; r < numRows; r++) - for(int c = 0; c < numCols; c++) + for(int r = 0; r < numRows; r++){ + for(int c = 0; c < numCols; c++){ double rand = Math.random(); lights[r][c] = rand < 0.4; - + } + } } /** Evaluates a light in row index row and column index col and returns a status @@ -28,13 +29,16 @@ public boolean evaluateLight(int row, int col) /* to be implemented in part (b) */ int count = 0; for(int r = 0; r < lights.length; r++){ - if(lights[r][col]) + if(lights[r][col]){ count++; + } } - if(lights[row][col] && count%2 == 0) + if(lights[row][col] && count%2 == 0){ return false; - if(!lights[row][col] && count%3 == 0) + } + if(!lights[row][col] && count%3 == 0){ return true; + } return lights[row][col]; } public boolean[][] getLights()