Question: Given the following method, what would be returned given the following board state when checking for O ? { { O ,

Given the following method, what would be returned given the following board state when checking for O?
{{" O "," X "," O "},
{" O "," X ","-"},
{" O ","-"," X "}}
public static int checkForColumnWin(String[][] board, char player){
// Variable to track row that holds a win
int colNumber =0;
for(int col =0; col <3; col++){
if(board[0][col].equals(""+ player +"") && board[1][col].equals(""+ player +"") && board[2][col].equals(""+ player +"")){
// Correct for human count (starting with 1, not 0)
colNumber = col +1;
break;
}
}
// If colNumber >0, there is a winning row
return colNumber;
}
0
2
1
3

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!