I have my connect four game but the checkwin algorithms won't work I have two other files called GameBoard and BoardSquare. The BoardSquare file sets the colors and types for the checkered pieces and the GameBoard file sets the 2d array...Can anyone tell me whats wrong?
public class ConnectFour extends JFrame { // making a gameboard object static JLabel label = new JLabel(" "); static GameBoard board = new GameBoard(); static public int i=2; static final int empty = 1; static boolean win = false; static int CurrentPlayer = 0; public ConnectFour() { setLayout(new BorderLayout()); // putting board on frame add(board,BorderLayout.CENTER); add(label,BorderLayout.NORTH); } public static void main(String[] args) { //setting my frame to the connect four frame JFrame frame = new ConnectFour(); frame.setSize(700, 600); frame.setLocationRelativeTo(null); // Center the frame frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } public static void updateBoard(int row, int col){ //checks to see if spot is empty //two seprate loops to find bottom square in column // BoardSquare clicked = board.Array[row][col]; //if its empty then change the players turn int l = row-1; while(row<5 && board.Array[row+1][col].GetType() == empty){ clicked = board.Array[row+1][col]; row = row+1; } if (clicked.GetType() == 1){ clicked.setType(i); if (i==3){ i=2; label.setText("red's turn"); checkWin(board.Array); } else{ i=3; label.setText("blacks turn"); checkWin(board.Array); } } } public static void checkWin(BoardSquare [][]board){ int numMove = 42; win = false; checkHorizontal(6, 7); checkVertical(6, 7); checkBackDiag(6, 7); checkDiag(6, 7); //checks for tie game if(win == false && numMove == 6*7){ System.out.println("Tie"); } } public static void checkHorizontal (int row, int column){ // checks for a horizontal win int count = 0; for (int i = 0; i < 6 && board.Array[row][i].GetType() == CurrentPlayer; i++){ count++; // increase count for every continuous piece from the same player } for (int i = 0; i >= 0 && board.Array[row][i].GetType()== CurrentPlayer; i--){ count++; } if (count >= 4){ // if count is greater then the number of continuous pieces required to win, the current player is declared the winner win = true; System.out.print("you win"); //declares a win } } //checks for a vertical win public static void checkVertical (int row, int column){ int count = 0; for (int i = row; i < row && board.Array[column][i].GetType() == CurrentPlayer; i++){ count++; // increase count for every continuous piece from the same player } for (int i = row; i < row && board.Array[column][i].GetType() == CurrentPlayer; i--){ count++; } if (count >= 4){ win = true; System.out.print("you win"); //declares a win } } public static void checkDiag (int row, int column){ int count = 0; int j; for (i = row, j = column;i >= 0 && j < 6 && board.Array[i][j].GetType()==CurrentPlayer;i--,j++){ count++; } for (i = row, j = column;i >= 0 && j < 6 && board.Array[i][j].GetType()==CurrentPlayer;i++,j--){ count++; } if (count >=4){ win = true; } } public static void checkBackDiag(int row, int column){ int count = 0; int j; for (i = row, j = column;i >= 0 && j < 6 && board.Array[i][j].GetType()==CurrentPlayer;i++,j++){ count++; } for (i = row, j = column;i >= 0 && j < 6 && board.Array[i][j].GetType()==CurrentPlayer;i--,j--){ count++; } if (count >= 4){ win = true; System.out.println("Winner"); } } }