package ru.job4j.chess.model;

import ru.job4j.chess.exceptions.ImpossibleMoveException;

/**
 * This class describes figure of elephant at the chess.
 *
 * @author Kucykh Vasily (mailto:basil135@mail.ru)
 * @version $Id$
 * @since 20.04.2017
 */
public class Bishop extends Figure {

    /**
     * constructor of class Bishop.
     *
     * @param position is position of the figure
     * @param fraction is fraction
     */
    public Bishop(final Cell position, final Fraction fraction) {
        super(position, fraction);
    }

    /**
     * method look the way to destination cell.
     *
     * @param destination is cell as destination on the board.
     * @return array of cell as the way to destination
     * @throws ImpossibleMoveException if this figure can't move to destination cell
     */
    @Override
    public Cell[] way(final Cell destination) throws ImpossibleMoveException {

        if (Math.abs(position.getX() - destination.getX()) != Math.abs(position.getY() - destination.getY())
                                                                    || position.getX() == destination.getX()) {

            throw new ImpossibleMoveException();

        }

        Cell[] result = new Cell[Math.abs(position.getX() - destination.getX())];

        Cell source = position;

        for (int i = 0; i < result.length; i++) {
            source = new Cell(rule(source.getX(), destination.getX()), rule(source.getY(), destination.getY()));
            result[i] = source;
        }

        return result;

    }

    /**
     * method clone figure and return new figure.
     *
     * @param destination is cell as position of new figure
     * @return clone figure
     */
    @Override
    public Figure clone(Cell destination) {
        return new Bishop(destination, this.fraction);
    }

}

@@ -914,32 +914,37 @@
 f (Math.abs(
-p
+getP
 osition
+()
 .getX() - de
@@ -969,32 +969,37 @@
 != Math.abs(
-p
+getP
 osition
+()
 .getY() - de
@@ -1087,24 +1087,29 @@
      %7C%7C 
-p
+getP
 osition
+()
 .getX() 
@@ -1237,24 +1237,29 @@
 ath.abs(
-p
+getP
 osition
+()
 .getX() 
@@ -1305,24 +1305,29 @@
 ource = 
-p
+getP
 osition
+()
 ;%0A%0A     
@@ -1821,24 +1821,29 @@
 n, this.
-f
+getF
 raction
+()
 );%0A    %7D

Refactor Bishop.java