@@ -0,0 +1,2932 @@
+package ru.matevosyan.Figures;%0A%0Aimport ru.matevosyan.exceptions.FigureNotFoundException;%0Aimport ru.matevosyan.exceptions.ImpossibleMoveException;%0Aimport ru.matevosyan.models.Cell;%0Aimport ru.matevosyan.models.Figure;%0A%0A/**%0A * Created Rook as one of figures.%0A * Created on 29.01.2017.%0A * @since 1.0%0A * @author Matevosyan Vardan%0A * @version 1.0%0A */%0A%0Apublic class Rook extends Figure %7B%0A%0A    /**%0A     * Rook name.%0A     */%0A%0A    private final String name = %22Rook%22;%0A%0A    /**%0A     * Rook constructor invoke parent constructor which assign Cell position.%0A     * @param position Rook position.%0A     */%0A%0A    public Rook(Cell position) %7B%0A        super(position);%0A    %7D%0A%0A    /**%0A     * Method way find the rook movement and assign to Cell array which is returning in the end.%0A     * And we get all the way that bishop is getting.%0A     * @param dist the way that we want to get.%0A     * @return rookWay that is actually array of cell or array of movement.%0A     * @throws ImpossibleMoveException throw when move is imposable.%0A     */%0A%0A    @Override%0A    public Cell%5B%5D way(Cell dist) throws ImpossibleMoveException %7B%0A%0A        Cell%5B%5D rookWay = new Cell%5B7%5D;%0A        Cell cellRook = new Cell();%0A        int i = 0;%0A%0A        /**%0A         * Get Cell distance X and Y getting from passing to method way.%0A         */%0A%0A        int distX = dist.getX();%0A        int distY = dist.getY();%0A%0A        /**%0A         * Get Cell current position X and Y getting from passing to method way.%0A         */%0A%0A        int currentDistX = this.position.getX();%0A        int currentDistY = this.position.getY();%0A%0A        if (distY %3E currentDistY & distX == currentDistX) %7B%0A            cellRook.setX(currentDistX);%0A            do %7B%0A                cellRook.setY(++currentDistY);%0A                rookWay%5Bi++%5D = cellRook;%0A            %7D while (currentDistY != distY);%0A        %7D else %7B%0A            cellRook.setX(currentDistX);%0A            do %7B%0A                cellRook.setY(--currentDistY);%0A                rookWay%5Bi++%5D = cellRook;%0A            %7D while (currentDistY != distY);%0A        %7D%0A%0A        if (distX %3E currentDistX) %7B%0A            cellRook.setY(currentDistY);%0A            do %7B%0A                cellRook.setX(++currentDistX);%0A                rookWay%5Bi++%5D = cellRook;%0A            %7D while (currentDistX != distX);%0A        %7D else %7B%0A            cellRook.setY(currentDistY);%0A            do %7B%0A                cellRook.setX(--currentDistX);%0A                rookWay%5Bi++%5D = cellRook;%0A            %7D while (currentDistX != distX);%0A        %7D%0A%0A        return rookWay;%0A    %7D%0A%0A    /**%0A     * Override clone method in Figure class which is actually abstract.%0A     * @param destination the way that we want to get.%0A     * @return new rook instance.%0A     * @throws FigureNotFoundException that is men that clone can not find figure in destination position.%0A     */%0A%0A    @Override%0A    public Figure clone(Cell destination) throws FigureNotFoundException %7B%0A        return new Rook(destination);%0A    %7D%0A%0A%0A%7D%0A

Create new Rook class and implement way method which return the rook movement array