Question: import java.util.*; public class PoD { /** * Validates that a 3x3 Tic-Tac-Toe game board is a valid board. * i.e. a board that has
import java.util.*;
public class PoD {
/**
* Validates that a 3x3 Tic-Tac-Toe game board is a valid board.
* i.e. a board that has at most one more x than o on it.
* @param gameBoard String[3][3] that holds game board info
* @return True if valid board, false otherwise.
*/
public static boolean validateBoard(String[][] gameBoard) {
boolean validBoard;
//PLEASE START YOUR WORK HERE
//PLEASE END YOUR WORK HERE
return (validBoard);
}
public static void main(String[] args) {
//Instantiate new scanner to read from the console.
Scanner in = new Scanner( System.in );
int gamePiece;
String[][] ticTacToeBoard = new String[3][3];
for (int i=0; i
{
for (int j=0; j
Instructions You are going to write a method to be called Beard that is going to validate whether or not a Tic-Tac-Torboard is possible Tic-Tac Toe is played on a 3 by 3 board and players to burns placing either and board. We will assume that in Tic-Tac Toe the player placingx wilgo first and that will go second. Learn more about the game here: http://en.wikipedia.org/wiki/Tic-tac-toe As the player placing x pieces goes first and play a s a valid board is one in which there is either the same number of one more x game pieces on the board as there are o game pieces The board is represented by a 3 by 3 array that holds strings that represent the game piece at each location. A space can hold any of the following . "x", representing an xgame piece in that position - "o". representingan game piece in that position . .".representing an empty position on the board Write the body of the program Details The main method of the program has been completed for you. You are to create the method called validateboard' which is called from the main method. The validateBoard method should take a 2D array as input and returna boolean value Details of this method se below Input The validateBoard method should take as input - 2-dimensional ray that holds strings representing the 3 by 3 game board where strings "X","o" and ".denoting the game piece in each location, as described above Processing The new method will decide whether the incoming 2D array is represents a valid board. A valid board is defined to be a board in which there are either the same number of a game pieces of one more than a Output I the board is determined to be valid the method will retum a boolean value of true. Otherwise, it will return false Sample Input/output Sample input Sample output true false 2 3 CSC 1110 author your lane 6 - import java.util. : 8 - public class Poo - Validates that a 3x3 Tic Tac Toe e board is a valid board. - i.e. & board that has at most one more x than o on it. - para fameBoard String(313) that holds game board info - Preturn True if valid board, false otherwise. public static boolean validateBoard(String gameBoard) { boolean validBoard: //PLEASE START YOUR WORK HERE //PLEASE END YOUR WORK HERE return (validBoard): public static void main(String[] args) { Scanner in- newscanner(System.in); Int game Piece: MMMM String tictactoeboard - new String[3][3]; for (int i e; i 3; 1) for (int j ; ; ; ;-) //Read in board ticTec Toeboard[i]0) - in.next(); //Output board if ( 2) System.out.print(tictactoe Board[i][j] " "); System.out.println(tictactoeBoard[i][j]); if (validateBoard(tictactoeBoard)) { System.out.println("Valid board"); else { System.out.println("Invalid board") {
//Read in board
ticTacToeBoard[i][j] = in.next();
//Output board
if (j
{
System.out.print(ticTacToeBoard[i][j] + " ");
}
else
{
System.out.println(ticTacToeBoard[i][j]);
}
}
}
if (validateBoard(ticTacToeBoard)) {
System.out.println("Valid board");
}
else {
System.out.println("Invalid board");
}
}
}


Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
