package uebung06;

public class Sudoku {
    private Field[][] board;

    public Sudoku() {
        board = new Field[9][9];
        createEmptyboard();
    }

    public Field getField(int x, int y){
        return board[x][y];
    }

    public void setField(int x, int y, VALUE value){
        board[x][y].setValue(value);
    }

    private void createEmptyboard() {
        for (int i = 0; i < 9; i++) {
            for (int j = 0; j < 9 ; j++) {
                board[i][j] = new Field(this, i, j);
            }
        }
    }

    @Override
    public String toString() {
        StringBuilder str = new StringBuilder();
        
        for (int i = 0; i < board.length; i++) {
            for (int j = 0; j < board.length; j++) {
                str.append(board[i][j].toString() + " ");

                if (j == 2 || j == 5) {
                    str.append("| ");
                }
            }
            str.append("\n");

            if (i == 2 || i ==5) {
                str.append("------+-------+------\n");
            }
        }

        return str.toString();
    }

    public void initialize(int[] values) {
        int c = 0;

        for (int i = 0; i < board.length; i++) {
            for (int j = 0; j < board.length; j++) {
                board[i][j].setValue(VALUE.of(values[c]));
                c++;
            }
        }
    }

    public boolean solve() {
        


        return true;
    }
}
