package uk.ac.aber.cs31920.assignment.implementation.datastructures;

import java.util.LinkedList;
import java.util.List;

/**
 * Represents a grid of squares as booleans, a true cell is "blocked"/"filled", a false
 * cell is empty.
 */
public class ProblemGrid {
    // true is filled, false is empty
    private Boolean[][] grid;
    public final int size;

    public ProblemGrid(int size) {
       this.size = size;
       grid = new Boolean[size][size];
    }

    public Boolean[][] getContents(){
        return grid;
    }

    public void setGridValue(int x, int y, boolean value) {
        if (x < 0 || y < 0 || x > this.size-1 || y > this.size-1)
            throw new ArrayIndexOutOfBoundsException();

        grid[y][x] = value;
    }

    @Override
    public String toString(){
        StringBuilder builder = new StringBuilder();
        for (Boolean[] row : grid){
           for (Boolean cell : row){
              builder.append(cell?"1":"0"); 
           }
           builder.append("\n");
        }

        return builder.toString();
    }
}
