check column
Sat May 20 2023 14:54:31 GMT+0000 (Coordinated Universal Time)
Saved by
@gokulz
/**
* Function Name: checkColoumns
* @param board
* @return count (int)
* Inside the function
* -->will check every column for a straight X or straight O
* -->The outer loop picks a column. The inner loop will index each row for that column.
*
*/
public static int checkColoumns(char[][] board){
int count =0;
for(int i=0; i<board.length; i++){
for(int j=0; j<board.length;j++){
if(board[j][i]=='X'){
count++;
}
else if(board[j][i]=='O'){
count--;
}
}
if(count==3 || count ==-3){
return count;
}
else{
count =0;
}
}
return count;
}
content_copyCOPY
Comments