package ru.job4j.figure;

import ru.job4j.game.*;

/**.
* Chapter_002
* Task 2.9.2
* Create class Bishop
*
* @author Anton Vasilyuk
* @version 1.0
* @since 0.1
*/

public class Bishop extends Figure {

	/**.
	* @cellPosition position figure
	*/
	private Cell position;

    /**.
     * Constructor for class Bishop
     * @param position is position figure
     */
    public Bishop(Cell position) {
        super(position);
    }

    /**.
     * Method is getter cell
     */
	@Override
    public Cell getCell() {
        return this.position;
    }

    /**.
     * Method for check validate way this figure
     * @param cell point
     * @return array from cell
     */
    @Override
    public Cell[] way(Cell cell) throws ImposibleMoveException {

        Board board = new Board();
        Cell[] cells;

        int srcRow = this.position.getRow();
        int srcCol = this.position.getCol();
        int disRow = cell.getRow();
        int disCol = cell.getCol();

        for (int index = 0; index < board.getFigures().length; index++) {
            if (board.getFigures()[index].getCell().getRow() == cell.getRow() &&
                    board.getFigures()[index].getCell().getCol() == cell.getCol()) {
                throw new ImposibleMoveException("It cell is busy, make outher choice");
            }
        }
        if (disRow > 7 && disRow < 0 && disCol > 7 && disCol < 0) {
            throw new ImposibleMoveException("incorrect choice, change outher cell");
        } else if (srcRow == disRow && srcCol == disCol) {
            throw new ImposibleMoveException("this figure nowhere walk, change correct choice");
        } else if (srcRow == disRow || srcCol == disCol) {
            throw new ImposibleMoveException("this figure can not so walk, change correct choice");
        } else if (srcRow == disRow && srcCol != disCol) {
            cells = new Cell[Math.abs(disCol - srcCol)];
            if (srcCol < disCol) {
                for (int i = 0; i < Math.abs(disCol - srcCol); i++) {
                    cells[i] = new Cell(srcRow, srcCol + i);
                }
            } else {
                for (int i = 0; i < Math.abs(disCol - srcCol); i++) {
                    cells[i] = new Cell(srcRow, srcCol - i);
                }
            }
            return cells;
        } else if (srcRow != disRow && srcCol == disCol) {
            cells = new Cell[Math.abs(disRow - srcRow)];
            if (srcRow < disRow) {
                for (int i = 0; i < Math.abs(disRow - srcRow); i++) {
                    cells[i] = new Cell(srcRow + i, srcCol);
                }
            } else {
                for (int i = 0; i < Math.abs(disCol - srcCol); i++) {
                    cells[i] = new Cell(srcRow - i, srcCol);
                }
            }
            return cells;
        } else {
            System.out.println("You destroy my programm");
            return cells = null;
        }
    }
}
@@ -199,76 +199,8 @@
  %7B%0A%0A
-%09/**.%0A%09* @cellPosition position figure%0A%09*/%0A%09private Cell position;%0A%0A
     
@@ -254,17 +254,21 @@
  @param 
-p
+cellP
 osition 
@@ -317,17 +317,21 @@
 op(Cell 
-p
+cellP
 osition)
@@ -351,139 +351,21 @@
 per(
-position);%0A    %7D%0A%0A    /**.%0A     * Method is getter cell%0A     */%0A%09@Override%0A    public Cell getCell() %7B%0A        return this.p
+cellP
 osition
+)
 ;%0A  
@@ -627,16 +627,84 @@
 %5D cells;
+%0A%09%09Figure%5B%5D figure = board.getFigures();%0A        board.fillFigure();
 %0A%0A      
@@ -715,33 +715,37 @@
 t srcRow = this.
-p
+cellP
 osition.getRow()
@@ -772,17 +772,21 @@
  = this.
-p
+cellP
 osition.
@@ -867,25 +867,24 @@
 tCol();%0A
-%0A
         
 for (int
@@ -879,62 +879,33 @@
     
-for (
 int 
+l
 in
-dex = 0; index %3C board.getF
+e = f
 igure
-s()
 .length;
  ind
@@ -904,202 +904,65 @@
 gth;
- index++) %7B%0A            if (board.getFigures()%5Bindex%5D.getCell().get
+%0A%0A        if (src
 Row
-()
  == 
-cell.get
+dis
 Row
-()
  &&
-%0A                    board.getFigures()%5Bindex%5D.getCell().get
+ src
 Col
-()
  == 
-cell.get
+dis
 Col
-()
 ) %7B%0A
-                
+%09%09%09
 thro
@@ -1030,30 +1030,16 @@
 oice%22);%0A
-            %7D%0A
         
@@ -1059,26 +1059,26 @@
 (disRow %3E 7 
-&&
+%7C%7C
  disRow %3C 0 
@@ -1077,18 +1077,18 @@
 Row %3C 0 
-&&
+%7C%7C
  disCol 
@@ -1091,18 +1091,18 @@
 Col %3E 7 
-&&
+%7C%7C
  disCol 
@@ -1354,167 +1354,8 @@
 %22);%0A
-        %7D else if (srcRow == disRow %7C%7C srcCol == disCol) %7B%0A            throw new ImposibleMoveException(%22this figure can not so walk, change correct choice%22);%0A
     
@@ -1629,16 +1629,20 @@
 cCol + i
+ + 1
 );%0A     
@@ -1803,16 +1803,20 @@
 cCol - i
+ - 1
 );%0A     
@@ -2139,16 +2139,20 @@
 cRow + i
+ + 1
 , srcCol
@@ -2313,16 +2313,20 @@
 cRow - i
+ - 1
 , srcCol

add file for chapter_002_2.9.2