package ru.agolovin.models;

/**
 * Class for chess board.
 *
 * @author agolovin (agolovin@list.ru)
 * @version $Id$
 * @since 0.1
 */
class Board {

    /**
     * max size row and column on the board.
     */
    private final int maxSize = 8;

    /**
     * array of figure on the board.
     */
    private Figure[][] board = new Figure[maxSize][maxSize];

    /**
     * Set figure to the board.
     * @param figure Figure
     */
    void setFigure(Figure figure) {
        int col = figure.getPosition().getCol();
        int row = figure.getPosition().getRow();
        this.board[col][row] = figure;
    }

    /**
     * check correct move figure.
     *
     * @param start cell
     * @param end   cell
     * @return true if correct move
     * @throws ImpossibleMoveException error
     * @throws FigureNotFoundException error
     * @throws OccupiedWayException    error
     */
    final boolean move(final Cell start, final Cell end)
            throws ImpossibleMoveException,
            FigureNotFoundException, OccupiedWayException {
        boolean result = false;
        final int maxIndex = 7;

           int startCol = start.getCol();
            int startRow = start.getRow();
            if (startCol < 0 || startRow < 0
                    || startCol > maxIndex
                    || startRow > maxIndex
                    || (board[startCol][startRow] == null)) {
                throw new FigureNotFoundException(
                        "Error: Figure not found on the board");
            }

            if (end.getCol() < 0
                    || end.getCol() > maxIndex
                    || end.getRow() < 0
                    || end.getRow() > maxIndex) {
                throw new ImpossibleMoveException(
                        "Error: Destination out of the board");
            }

            Cell[] way = board[startCol][startRow].way(end);

            for (Cell element : way) {
                if (element == null) {
                    break;
                }

                if (board[element.getCol()][element.getRow()] != null) {
                    throw new OccupiedWayException(
                            "Another figure on the way");
                }
            }

            board[end.getCol()][end.getCol()] =
                    board[startCol][startRow].clone(end);

            board[startCol][startRow] = null;

            result = true;


        return result;
    }
}

@@ -392,24 +392,31 @@
  the board.%0A
+     *%0A
      * @para
@@ -1087,12 +1087,11 @@
 t = 
-fals
+tru
 e;%0A 
@@ -1122,35 +1122,32 @@
 x = 7;%0A%0A        
-   
 int startCol = s
@@ -1165,28 +1165,24 @@
 ();%0A        
-  
-  
 int startRow
@@ -1204,28 +1204,24 @@
 ();%0A        
-  
-  
 if (startCol
@@ -1249,36 +1249,32 @@
                 
-    
 %7C%7C startCol %3E ma
@@ -1288,36 +1288,32 @@
                 
-   
- 
 %7C%7C startRow %3E ma
@@ -1311,36 +1311,32 @@
 tRow %3E maxIndex%0A
-    
                 
@@ -1373,28 +1373,24 @@
 == null)) %7B%0A
-    
             
@@ -1436,36 +1436,32 @@
                 
-    
 %22Error: Figure n
@@ -1485,36 +1485,32 @@
 oard%22);%0A        
-    
 %7D%0A%0A            i
@@ -1500,28 +1500,24 @@
  %7D%0A%0A        
- 
-   
 if (end.getC
@@ -1521,28 +1521,24 @@
 etCol() %3C 0%0A
-    
             
@@ -1576,36 +1576,32 @@
                 
-  
-  
 %7C%7C end.getRow() 
@@ -1600,28 +1600,24 @@
 etRow() %3C 0%0A
-    
             
@@ -1654,36 +1654,32 @@
 ) %7B%0A            
-   
- 
 throw new Imposs
@@ -1689,36 +1689,32 @@
 eMoveException(%0A
-    
                 
@@ -1753,28 +1753,24 @@
 he board%22);%0A
-    
         %7D%0A%0A 
@@ -1776,20 +1776,16 @@
         
-    
 Cell%5B%5D w
@@ -1834,20 +1834,16 @@
         
-    
 for (Cel
@@ -1869,28 +1869,24 @@
             
- 
-   
 if (element 
@@ -1912,20 +1912,16 @@
         
-    
 break;%0A 
@@ -1927,35 +1927,27 @@
             
-  
-  
 %7D%0A%0A
-    
             
@@ -2011,36 +2011,32 @@
                 
-   
- 
 throw new Occupi
@@ -2075,20 +2075,16 @@
         
-    
 %22Another
@@ -2101,28 +2101,24 @@
  the way%22);%0A
-    
             
@@ -2123,35 +2123,27 @@
   %7D%0A        
-    %7D%0A%0A    
+%7D%0A%0A
         boar
@@ -2182,36 +2182,32 @@
                 
- 
-   
 board%5BstartCol%5D%5B
@@ -2229,36 +2229,32 @@
 (end);%0A%0A        
-    
 board%5BstartCol%5D%5B
@@ -2276,37 +2276,8 @@
 l;%0A%0A
-            result = true;%0A%0A%0A
     

fix task 7.2