Question
Write a public static method int [] findX w in(char [] board) The purpose of this method is to determine whether X has won at
Write a public static method int [] findXwin(char [] board)
The purpose of this method is to determine whether X has won at 6 by 6 tic tac toe and if so to return the four square numbers that make up the win.
The parameter board is a one dimensional array of length 37 used to represent a 6 by 6 tictactoe board.
The first row is represented by board[1], board[2], board[3], board[4], board[5], board[6].
The second row is represented by board[7], board[8], board[9], board[10], board[11], board[12].
And similarly for rows three though six, so the lower right square is represented by board[36]. Note that board[0] is ignored.
The method should return an array of size 4 or null.
if there are four adjacent 'X's when board is viewed as a 6 by 6 grid then the return value will be an array with the square numbers that contain the four X's. The square numbers must be arranged in ascending order.
By "adjacent" we mean four adjacent (i.e. contiguous) X's within a row, column or diagonal, when board is viewed as a 6 by 6 grid.
For example, if elements board[8], board[15], board[22] and board[29] are all 'X' then the method would return the array with contents {8, 15, 22, 29}.
Similarly if board[4], board[9], board[14] and board[19] are all 'X' then the return value would be the array with contents {4, 9, 14, 19}.
If there is no set of four adjacent X's then the method should return null.
You can assume that at most one set of adjacent squares have four 'X's in them, i.e. the result is never indeterminate.
There is no assumption about what's in the "not X" squares; each one could be any character.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started