package ru.szhernovoy.view;

/**
 * Created by Sergey on 17.09.2016.
 */

public class TicTacToe {

    private final int[][] values;

    public TicTacToe(final int[][] values) {
        this.values = values;
    }

    public boolean hasWinner() {

        int [] xyLine = new int[]{-1, -1};
        int [] xyColumne = new int[]{-1, -1};
        int [] xyDiagonal = new int[]{-1, -1};
        int [] xyDiagonalL = new int[]{-1, -1};



        int accumaleteLine = 0;
        int accumaleteColumne = 0;
        int accumaleteDiagonal = 0;
        int accumaleteDiagonalL = 0;


        //up - down ; left - rigth
        for(int i = 0, k =0, v = this.Board.length -1 ; i < this.Board.length;i++, k++,v--){

            /**
             * Calculate diagonal left to right
             */

            if(this.Board[i][k] == symbol){
                accumaleteDiagonal++;
            }
            else{
                xyDiagonal[0] = i;
                xyDiagonal[1] = k;
            }

            /**
             * Calculate diagonal right to left
             */
            if(this.Board[i][v] == symbol){
                accumaleteDiagonalL++;
            }
            else{
                xyDiagonalL[0] = i;
                xyDiagonalL[1] = v;
            }


            for(int j = 0; j < this.Board.length;j++){
                /**
                 * Calculate line
                 */
                if(this.Board[i][j] == symbol){
                    accumaleteLine++;
                }
                else{
                    xyLine[0] = i;
                    xyLine[1] = j;
                }

                /**
                 * Calculate column
                 */
                if(this.Board[j][i] == symbol){
                    accumaleteColumne++;
                }
                else{
                    xyColumne[0] = j;
                    xyColumne[1] = i;
                }
            }

            if(accumaleteLine == 2  ){
                xy = xyLine;
                break;
            }
            else{
                xyLine[0] = -1;
                xyLine[1] = -1;
                accumaleteLine = 0;
            }

            if(accumaleteColumne == 2  ){
                xy = xyColumne;
                break;
            }
            else{
                xyColumne[0] = -1;
                xyColumne[1] = -1;
                accumaleteColumne = 0;
            }
        }

        if(xy[0] == -1 && xy[1] ==-1 ){
            if(accumaleteDiagonal == 2  ){
                xy = xyDiagonal;
            }

            if(accumaleteDiagonalL == 2  ){
                xy = xyDiagonalL;
            }
        }

        throw new UnsupportedOperationException();
    }
}


@@ -572,16 +572,19 @@
 L = 0;%0A%0A
+/*%0A
 %0A       
@@ -709,32 +709,35 @@
 )%7B%0A%0A            
+*/%0A
 /**%0A            
@@ -787,16 +787,19 @@
       */
+/*%0A
 %0A%0A      
@@ -995,32 +995,35 @@
  %7D%0A%0A            
+*/%0A
 /**%0A            
@@ -1065,32 +1065,35 @@
 %0A             */
+/*%0A
 %0A            if(
@@ -1343,32 +1343,35 @@
                 
+*/%0A
 /**%0A            
@@ -1403,32 +1403,35 @@
               */
+/*%0A
 %0A               
@@ -1646,16 +1646,19 @@
         
+*/%0A
 /**%0A    
@@ -1708,16 +1708,19 @@
       */
+/*%0A
 %0A       
@@ -2666,32 +2666,32 @@
 ;%0A            %7D%0A
-
         %7D%0A%0A     
@@ -2675,32 +2675,35 @@
      %7D%0A        %7D
+%0A*/
 %0A%0A        throw 

update map , without override Euqals HashCod