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

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

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!