package ru.job4j.chess.model;

import ru.job4j.chess.exceptions.ImpossibleMoveException;

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

    /**
     * constructor of this figure.
     *
     * @param position is the position of this figure on the board
     * @param fraction is the fraction
     */
    public Queen(Cell position, Fraction fraction) {
        super(position, fraction);
    }

    /**
     * method describes a way of this figure from position to destination.
     *
     * @param destination is cell as destination on the board.
     * @return array of cell as way from position to destination
     * @throws ImpossibleMoveException if this figure can not move from position to destination
     */
    @Override
    Cell[] way(Cell destination) throws ImpossibleMoveException {

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

            throw new ImpossibleMoveException();

        }

        int size = position.getX() == destination.getX() ? Math.abs(position.getY() - destination.getY())
                                                         : Math.abs(position.getX() - destination.getX());

        Cell[] result = new Cell[size];

        Cell source = position;

        for (int count = 0; count < result.length; count++) {

            source = new Cell(rule(source.getX(), destination.getX()), rule(source.getY(), destination.getY()));
            result[count] = 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 Queen(destination, this.fraction);
    }

}

@@ -946,24 +946,29 @@
    if ((
-p
+getP
 osition
+()
 .getX() 
@@ -988,32 +988,37 @@
 n.getX() && 
-p
+getP
 osition
+()
 .getY() != d
@@ -1057,32 +1057,37 @@
 & (Math.abs(
-p
+getP
 osition
+()
 .getX() - de
@@ -1112,32 +1112,37 @@
 != Math.abs(
-p
+getP
 osition
+()
 .getY() - de
@@ -1175,24 +1175,29 @@
      %7C%7C 
-p
+getP
 osition
+()
 .getX() 
@@ -1221,24 +1221,29 @@
 tX() && 
-p
+getP
 osition
+()
 .getY() 
@@ -1348,24 +1348,29 @@
  size = 
-p
+getP
 osition
+()
 .getX() 
@@ -1398,32 +1398,37 @@
  ? Math.abs(
-p
+getP
 osition
+()
 .getY() - de
@@ -1502,16 +1502,21 @@
         
+     
 : Math.a
@@ -1518,24 +1518,29 @@
 ath.abs(
-p
+getP
 osition
+()
 .getX() 
@@ -1626,24 +1626,29 @@
 ource = 
-p
+getP
 osition
+()
 ;%0A%0A     
@@ -2159,24 +2159,29 @@
 n, this.
-f
+getF
 raction
+()
 );%0A    %7D

Refactor Queen.java