package ru.job4j.chess.model;

import ru.job4j.chess.exceptions.ImpossibleMoveException;

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

    /**
     * parameter position describes the position of the figure.
     */
    final Cell position;

    /**
     * parameter fraction describes the fraction of the figure.
     */
    final Fraction fraction;

    /**
     * constructor of class Figure set figure to a position.
     *
     * @param position is position on the board
     * @param fraction is fraction of the chess application
     */
    Figure(final Cell position, final Fraction fraction) {
        this.position = position;
        this.fraction = fraction;
    }

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

    /**
     * method clone a figure and return new figure;
     *
     * @param destination is cell as position of new figure
     * @return clone figure
     */
    abstract Figure clone(Cell destination);

    /**
     * method describes changes if coordinates when figure move.
     *
     * @param one is the source number of coordinates
     * @param two is the second number of coordinates
     * @return number that bigger or smaller from position
     */
    int rule(int one, int two) {
        if (one > two) {
            return --one;
        } else if (one < two) {
            return ++one;
        } else {
            return one;
        }
    }

}
@@ -346,24 +346,32 @@
      */%0A    
+private 
 final Cell p
@@ -375,24 +375,24 @@
 l position;%0A
-
 %0A    /**%0A   
@@ -464,16 +464,24 @@
  */%0A    
+private 
 final Fr
@@ -1275,17 +1275,17 @@
 w figure
-;
+.
 %0A     *%0A
@@ -1860,24 +1860,24 @@
 return one;%0A
-
         %7D%0A  
@@ -1881,9 +1881,359 @@
 %0A    %7D%0A%0A
+    /**%0A     * method return position of figure.%0A     *%0A     * @return position of the figure%0A     */%0A    public Cell getPosition() %7B%0A        return this.position;%0A    %7D%0A%0A    /**%0A     * method return fraction of the figure.%0A     *%0A     * @return fraction of the figure%0A     */%0A    public Fraction getFraction() %7B%0A        return this.fraction;%0A    %7D%0A%0A
 %7D

Refactor Figure.java