chapter_002/src/main/java/ru/job4j/chess/Board.java
public boolean move(Cell source, Cell dist) throws ImpossibleMoveExeption, OccupiedWayException, FigureNotFoundException {

        if (source.getFigureInThisCell() == null) {
            throw new FigureNotFoundException();
        }

        Figure currentFigure = source.getFigureInThisCell();
        Cell[] ways = currentFigure.way(cells, dist);
        for (Cell cell : ways) {
            if (cell.getFigureInThisCell() != null) {
                throw new OccupiedWayException();
            }
        }

        Figure newFigure = currentFigure.clone(dist);
        dist.setFigureInThisCell(newFigure);

        source.setFigureInThisCell(null);
        for (int i = 0; i < this.figures.length; i++) {
            if (this.figures[i] == currentFigure) {
                this.figures[i] = newFigure;
                break;
            }
        }
        return true;
    }
/**
     * Move Figure.
     *
     * @param source Cell move from cell
     * @param dist   Cell move to cell
     * @return true if everything is good.
     * @throws ImpossibleMoveExeption trows ImpossibleMoveExeption
     * @throws OccupiedWayException trows OccupiedWayException
     * @throws FigureNotFoundException trows FigureNotFoundException
     */
Move Figure.
@param source Cell move from cell
@param dist   Cell move to cell
@return true if everything is good.
Move Figure . @param source Cell move from cell @param dist Cell move to cell @return true if everything is good .
public boolean move(Cell source, Cell dist) throws ImpossibleMoveExeption, OccupiedWayException, FigureNotFoundException {
        if (source.getFigureInThisCell() == null) {
            throw new FigureNotFoundException();
        }
        Figure currentFigure = source.getFigureInThisCell();
        Cell[] ways = currentFigure.way(cells, dist);
        for (Cell cell : ways) {
            if (cell.getFigureInThisCell() != null) {
                throw new OccupiedWayException();
            }
        }
        Figure newFigure = currentFigure.clone(dist);
        dist.setFigureInThisCell(newFigure);
        source.setFigureInThisCell(null);
        for (int i = 0; i < this.figures.length; i++) {
            if (this.figures[i] == currentFigure) {
                this.figures[i] = newFigure;
                break;
            }
        }
        return true;
    }
public boolean move ( Cell source , Cell dist ) throws ImpossibleMoveExeption , OccupiedWayException , FigureNotFoundException { if ( source . getFigureInThisCell ( ) == null ) { throw new FigureNotFoundException ( ) ; } Figure currentFigure = source . getFigureInThisCell ( ) ; Cell [ ] ways = currentFigure . way ( cells , dist ) ; for ( Cell cell : ways ) { if ( cell . getFigureInThisCell ( ) != null ) { throw new OccupiedWayException ( ) ; } } Figure newFigure = currentFigure . clone ( dist ) ; dist . setFigureInThisCell ( newFigure ) ; source . setFigureInThisCell ( null ) ; for ( int i = 0 ; i < this . figures . length ; i ++ ) { if ( this . figures [ i ] == currentFigure ) { this . figures [ i ] = newFigure ; break ; } } return true ; }
Move Figure.
Move Figure .