Write a program named Review.java and implement the following methods: public static boolean isValidTicTacToeBoardString(String str) This method takes as its parameter a String that contains 9 characters representing the status of the Tic Tact Toe game. The String is mixed with X, O, x, o, and other letters. The first three letters represent the first row, letter 4 through letter 6 represent the second row, and the rest for the last row. To be considered as a valid status, the String must meet the following condistions: 1. The absolute difference between the number of Xs and the number of Os must be either 0 or 1 2. There is only one or none player meeting the "win" condition (row, colum, diagonal) public static char[][] buildTicTactToe2DBoard(String str) This method takes as its parameter a String that contains 9 characters. The String is mixed with X, O, x, o, and other letters. If the argument string is valid board string, then construct a 2D arrray to represent the board. Use a peroid (.) to replace all other letters in the 2D array. For example, the string "XX9pOoOxR" should return the following 2D array: X X . . O O O X .

public class MyClass {
public static boolean isValidTicTacToeBoardString(String str)
{
// invalid length
if(str.length() != 9)
return false;
// absolute difference
int xs = 0, os = 0;
for(int i=0; i<9; i++)
{
if(str.charAt(i) == 'x' || str.charAt(i) == 'X')
xs++;
else if(str.charAt(i) == 'o' || str.charAt(i) == 'O')
os++;
}
if(xs-os != 0 && xs-os != -1 && xs-os != 1)
return false;
// No or one winner only
if( (
((str.charAt(0) == 'x' || str.charAt(0) == 'X') &&
(str.charAt(1) == 'x' || str.charAt(1) == 'X') &&
(str.charAt(2) == 'x' || str.charAt(2) == 'X')) ||
((str.charAt(3) == 'x' || str.charAt(3) == 'X') &&
(str.charAt(4) == 'x' || str.charAt(4) == 'X') &&
(str.charAt(5) == 'x' || str.charAt(5) == 'X')) ||
((str.charAt(6) == 'x' || str.charAt(6) == 'X') &&
(str.charAt(7) == 'x' || str.charAt(7) == 'X') &&
(str.charAt(8) == 'x' || str.charAt(8) == 'X')) ||
((str.charAt(0) == 'x' || str.charAt(0) == 'X') &&
(str.charAt(3) == 'x' || str.charAt(3) == 'X') &&
(str.charAt(6) == 'x' || str.charAt(6) == 'X')) ||
((str.charAt(1) == 'x' || str.charAt(1) == 'X') &&
(str.charAt(4) == 'x' || str.charAt(4) == 'X') &&
(str.charAt(7) == 'x' || str.charAt(7) == 'X')) ||
((str.charAt(2) == 'x' || str.charAt(2) == 'X') &&
(str.charAt(5) == 'x' || str.charAt(5) == 'X') &&
(str.charAt(8) == 'x' || str.charAt(8) == 'X')) ||
((str.charAt(0) == 'x' || str.charAt(0) == 'X') &&
(str.charAt(4) == 'x' || str.charAt(4) == 'X') &&
(str.charAt(8) == 'x' || str.charAt(8) == 'X')) ||
((str.charAt(2) == 'x' || str.charAt(2) == 'X') &&
(str.charAt(4) == 'x' || str.charAt(4) == 'X') &&
(str.charAt(6) == 'x' || str.charAt(6) == 'X'))
) &&
(
((str.charAt(0) == 'o' || str.charAt(0) == 'O') &&
(str.charAt(1) == 'o' || str.charAt(1) == 'O') &&
(str.charAt(2) == 'o' || str.charAt(2) == 'O')) ||
((str.charAt(3) == 'o' || str.charAt(3) == 'O') &&
(str.charAt(4) == 'o' || str.charAt(4) == 'O') &&
(str.charAt(5) == 'o' || str.charAt(5) == 'O')) ||
((str.charAt(6) == 'o' || str.charAt(6) == 'O') &&
(str.charAt(7) == 'o' || str.charAt(7) == 'O') &&
(str.charAt(8) == 'o' || str.charAt(8) == 'O')) ||
((str.charAt(0) == 'o' || str.charAt(0) == 'O') &&
(str.charAt(3) == 'o' || str.charAt(3) == 'O') &&
(str.charAt(6) == 'o' || str.charAt(6) == 'O')) ||
((str.charAt(1) == 'o' || str.charAt(1) == 'O') &&
(str.charAt(4) == 'o' || str.charAt(4) == 'O') &&
(str.charAt(7) == 'o' || str.charAt(7) == 'O')) ||
((str.charAt(2) == 'o' || str.charAt(2) == 'O') &&
(str.charAt(5) == 'o' || str.charAt(5) == 'O') &&
(str.charAt(8) == 'o' || str.charAt(8) == 'O')) ||
((str.charAt(0) == 'o' || str.charAt(0) == 'O') &&
(str.charAt(4) == 'o' || str.charAt(4) == 'O') &&
(str.charAt(8) == 'o' || str.charAt(8) == 'O')) ||
((str.charAt(2) == 'o' || str.charAt(2) == 'O') &&
(str.charAt(4) == 'o' || str.charAt(4) == 'O') &&
(str.charAt(6) == 'o' || str.charAt(6) == 'O'))
)
)
return false;
return true;
}
public static void main(String args[]) {
System.out.println("Correct: " + isValidTicTacToeBoardString("XX oX
oo"));
System.out.println("Has two winners: " +
isValidTicTacToeBoardString("XXXoX ooo"));
System.out.println("Invalid length: " +
isValidTicTacToeBoardString("XXXoX ooa aldf o"));
}
}
// Multiple questions found. Answered one. -- Policy
of Chegg. Please post accordingly.
Write a program named Review.java and implement the following methods: public static boolean isValidTicTacToeBoardString(String str) This...