package ru.sbulygin.chees;

import ru.sbulygin.exeptions.ImpossibleMoveException;

import static ru.sbulygin.chees.Cell.getObjectCell;

/**
 * Class Horse.
 *
 * @author ru.sbulygin.start.
 * @since 15.03.2017.
 * @version 1.0.
 */
public class Horse extends Figure {
    /**
     * An array field of the movement of an horse.
     */
    private Cell[] direction = new Cell[2];
    /**
     * Place the coordinates in the array.
     */
    private int spot = 0;

    /**
     * The constructor of the Horse class generates the class object.
     * @param position position of the figure on the Board.
     */
    public Horse(Cell position) {
        super(position);
    }

    /**
     * Way overridden method of the abstract class Figure.
     * @param distance the specified cell on the Board.
     * @return array of the path of movement of the horse.
     * @throws ImpossibleMoveException error of the impossibility of motion horse.
     */
    @Override
    public Cell[] way(Cell distance) throws ImpossibleMoveException {

        int posX = getPosition().getPivotX();
        int posY = getPosition().getPivotY();
        int distX = distance.getPivotX();
        int distY = distance.getPivotY();

        int vectorX = Math.abs(distX - posX);
        int vectorY = Math.abs(distY - posY);

        if (vectorX + vectorY == 3 && posX != distX && posY != distY) {
            direction[spot] = getObjectCell(posX, distX);
            direction[spot] = getObjectCell(posY, distY);
        } else {
            throw new ImpossibleMoveException("Horse can't walk.");
        }
        return direction;
    }
}

@@ -375,93 +375,8 @@
 %5B2%5D;
-%0A    /**%0A     * Place the coordinates in the array.%0A     */%0A    private int spot = 0;
 %0A%0A  
@@ -942,16 +942,37 @@
 ption %7B%0A
+        int spot = 0;
 %0A       
@@ -1324,32 +1324,34 @@
   direction%5Bspot
+++
 %5D = getObjectCel
@@ -1356,70 +1356,13 @@
 ell(
-posX, distX);%0A            direction%5Bspot%5D = getObjectCell(posY
+distX
 , di

add Tests class