Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public LightBoard(int numRows, int numCols) {
- lights = new boolean[numRows][numCols];
- for(int i = 0; i < numRows; i++) {
- for(int j = 0; j < numCols; j++) {
- boolean temp = Math.random() < .4;
- lights[i][j] = temp;
- }
- }
- }
- public boolean evaluateLight(int row, int col) {
- int numLights = 0;
- for(int i = 0; i < lights.length; i++) {
- if(lights[i][col]) {
- numLights++;
- }
- }
- if(lights[row][col]) {
- return (numLights % 2 == 1);
- }
- else {
- return (numLights % 3 == 0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment