// package com.nighthawk.spring_portfolio.mvc.lightboard;

// import lombok.Data;
import java.lang.Math;

// @Data  // Annotations to simplify writing code (ie constructors, setters)
public class LightBoard {
    // private Light[][] lights;

    private boolean [][] lights;

    //part a
    /* Initialize LightBoard and Lights */
    public LightBoard(int numRows, int numCols) {
        lights = new boolean [numRows][numCols];   
         // 2D array nested loops, used for initialization
        for (int r = 0; r < lights.length; r++) {
            for (int c = 0; c < lights[r].length; c++) {
                if (Math.random() <0.4){
                    lights[r][c]=true; 
                }
                else{
                    lights[r][c]=false;
                }
            }
        }
    }
}
  
    public boolean evaluateLight(int row, int col)
    {
        //check light is turned on
        int lightOn =0;
        
        if (lights[row][col]==true)
            for(int r=0; r<lights.length;r++)
            {
                if(lights[r][col]==true)
                {
                    lightOn++;
                }
            }
            if (lightOn % 2 == 0){
                if(lights[row][col]==0){
                    return false;
                }            
            }
            else{
                return true;
        }

        if (lightOn % 3 == 0) {
            return true;
        }
        else {
            return false;
        }
    // return lights[row][col];
    
}
//off for false
        // create and display LightBoard

public void tester()
{
lights[0][0]=true; lights[0][1]=true; lights[0][2]=false;lights[0][3]=true; lights[0][4]=true;
lights[1][0]=true; lights[1][1]=false;lights[1][2]=false;lights[1][3]=true; lights[1][4]=false;
lights[2][0]=true; lights[2][1]=false;lights[2][2]=false;lights[2][3]=true; lights[2][4]=true;
lights[3][0]=true; lights[3][1]=false;lights[3][2]=false;lights[3][3]=false;lights[3][4]=true;
lights[4][0]=true; lights[4][1]=false;lights[4][2]=false;lights[4][3]=false;lights[4][4]=true;
lights[5][0]=true; lights[5][1]=true; lights[5][2]=false;lights[5][3]=true; lights[5][4]=true;
lights[6][0]=false;lights[6][1]=false;lights[6][2]=false;lights[6][3]=false;lights[6][4]=false;
}
LightBoard lightboard = new LightBoard(5, 5);
System.out.println(lightboard.evaluateLight(0,1));
System.out.println(lightboard.evaluateLight(3,1));
System.out.println(lightboard.evaluateLight(0,2));
true
true
false