package com.java.laiy.model;

import com.java.laiy.helpers.CoordinateHelper;

public class Board {

    private static final int BOARD_SIZE = 3;

    private Figure[][] figures = new Figure[BOARD_SIZE][BOARD_SIZE];

    public Board(Figure[][] figures) {
        assert figures != null;
        this.figures = figures;
    }

    public boolean setFigure(final int x, final int y, final Figure figure) {
        if (!CoordinateHelper.checkCoordinate(x) || !CoordinateHelper.checkCoordinate(y) || figures[x][y] != null)  {
            return false;
        }
        else {
            figures[x][y] = figure;
            return true;
        }
    }

    public Figure getFigure(final int x, final int y) {
        if (!CoordinateHelper.checkCoordinate(x) || !CoordinateHelper.checkCoordinate(y)) {
            return null;
        }
        else {
            return figures[x][y];
        }
    }

    public Figure[][] getFiguresArray() {
            return figures;
    }

    public int getRowLength(final int row) {
        return figures[row].length;
    }

}

@@ -122,16 +122,24 @@
 nal int 
+DEFAULT_
 BOARD_SI
@@ -159,16 +159,22 @@
 private 
+final 
 Figure%5B%5D
@@ -187,34 +187,53 @@
 ures
- = new Figure%5BBOARD_SIZE%5D%5B
+;%0A%0A    public Board() %7B%0A        this(DEFAULT_
 BOAR
@@ -238,18 +238,24 @@
 ARD_SIZE
-%5D;
+);%0A    %7D
 %0A%0A    pu
@@ -269,38 +269,101 @@
 ard(
-Figure%5B%5D%5B%5D figures) %7B%0A
+final int customBoardSize) %7B%0A        if (customBoardSize %3C DEFAULT_BOARD_SIZE) %7B%0A    
         
 asse
@@ -362,23 +362,21 @@
     
-assert 
+this.
 figures 
 != n
@@ -375,48 +375,170 @@
 res 
-!
 = n
-ull;%0A        this.figures = figures;
+ew Figure%5BDEFAULT_BOARD_SIZE%5D%5BDEFAULT_BOARD_SIZE%5D;%0A        %7D%0A         else %7B%0A            this.figures = new Figure%5BcustomBoardSize%5D%5BcustomBoardSize%5D;%0A        %7D
 %0A   

Update Board.java