Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Next Generation Databases NoSQLand Big Data

Authors: Guy Harrison

1st Edition

1484213300, 978-1484213308

More Books

Students also viewed these Databases questions

Question

2 What are the advantages and disadvantages of job evaluation?

Answered: 1 week ago

Question

1 Name three approaches to job evaluation.

Answered: 1 week ago