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 {

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

    /**.
     * 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;
		Figure[] figure = board.getFigures();
        board.fillFigure();

        int srcRow = this.cellPosition.getRow();
        int srcCol = this.cellPosition.getCol();
        int disRow = cell.getRow();
        int disCol = cell.getCol();
		int positionRow = 0;
		int positionCol = 0;
        int line = 0;

        if (srcRow == disRow && srcCol == disCol) {
			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");
        }

		if (srcRow == disRow && srcCol == disCol) {
            throw new ImposibleMoveException("this figure nowhere walk, change correct choice");
        }

		if (srcRow == disRow || srcCol == disCol) {
			if (srcRow == disRow) {line = Math.abs(disCol - srcCol);}
			if (srcCol == disCol) {line = Math.abs(disRow - srcRow);}
            cells = new Cell[line];
			int rMove = disRow > srcRow ? 1 : disRow < srcRow ? -1 : 0;
			int cMove = disCol > srcCol ? 1 : disCol < srcCol ? -1 : 0;
			for (int i = 0; i < line; i++) {
				positionRow = positionRow + rMove;
				positionCol = positionCol + cMove;
				cells[i] = new Cell(positionRow, positionCol);
			}
		} else {
			throw new ImposibleMoveException("don't right choise");
		}
		return cells;
	}
}
@@ -369,30 +369,23 @@
 %0A    %7D%0A%0A
-    
+%09
 /**.%0A
-     
+%09
 * Method
@@ -399,101 +399,92 @@
 eck 
-validate way this figure%0A     * @param cell point%0A     * @return array from cell%0A     */%0A    
+may be way figure%0A%09* @dist finish cell way%0A%09* @return array cell is way figure%0A%09*/%0A%09
 @Ove
@@ -489,20 +489,17 @@
 verride%0A
-    
+%09
 public C
@@ -513,20 +513,20 @@
 ay(Cell 
-cell
+dist
 ) throws
@@ -552,24 +552,18 @@
 tion %7B%0A%0A
-        
+%09%09
 Board bo
@@ -581,24 +581,18 @@
 oard();%0A
-        
+%09%09
 Cell%5B%5D c
@@ -598,59 +598,12 @@
 cell
-s
 ;%0A%09%09
-Figure%5B%5D figure = board.getFigures();%0A        
 boar
@@ -738,20 +738,20 @@
 isRow = 
-cell
+dist
 .getRow(
@@ -774,20 +774,20 @@
 isCol = 
-cell
+dist
 .getCol(
@@ -793,85 +793,11 @@
 ();%0A
+%0A
 %09%09
-int positionRow = 0;%0A%09%09int positionCol = 0;%0A        int line = 0;%0A%0A        
 if (
@@ -922,24 +922,19 @@
       %7D%0A
-        
+%0A%09%09
 if (disR
@@ -1092,60 +1092,69 @@
 if (
-srcRow == disRow && srcCol == dis
+Math.abs(disRow - srcRow) != Math.abs(disCol - src
 Col)
+)
  %7B%0A
-            
+%09%09%09
 thro
@@ -1199,137 +1199,46 @@
 ure 
-nowhere walk,
+don't
  c
-h
 an
-ge correct choice%22);%0A        %7D%0A%0A%09%09if (srcRow == disRow %7C%7C srcCol == disCol) %7B%0A%09%09%09if (srcRow == disRow) %7Bline = 
+ go to the cell%22);%0A%09%09%7D%0A%09%09if (
 Math
@@ -1249,55 +1249,23 @@
 (dis
-Col
+Row
  - src
-Col);%7D%0A%09%09%09if (srcCol == disCol) %7Bline 
+Row) =
 = Ma
@@ -1278,355 +1278,75 @@
 (dis
-Row
+Col
  - src
-Row);%7D%0A            cells = new Cell%5Bline%5D;%0A%09%09%09int rMove = disRow %3E srcRow ? 1 : disRow %3C srcRow ? -1 : 0;%0A%09%09%09int cMove = disCol %3E srcCol ? 1 : disCol %3C srcCol ? -1 : 0;%0A%09%09%09for (int i = 0; i %3C line; i++) %7B%0A%09%09%09%09positionRow = positionRow + rMove;%0A%09%09%09%09positionCol = positionCol + cMove;%0A%09%09%09%09cells%5Bi%5D = new Cell(positionRow, positionCol);%0A%09%09%09%7D
+Col)) %7B%0A%09%09%09cell = routing(srcRow, srcCol, disRow, disCol);
 %0A%09%09%7D
@@ -1429,15 +1429,14 @@
 urn cell
-s
 ;%0A%09%7D%0A%7D

add file for chapter_002_2.9.2