Question: java Instructions You are going to write a method to be called validateBoard) that is going to validate whether or not a Tic-Tac-Toe board is

java
java Instructions You are going to write a method to be called
validateBoard") that is going to validate whether or not a Tic-Tac-Toe board
is possible. Tic-Tac-Toe is played on a 3 by 3 board and
players take turns placing either an xor an o on the board.

Instructions You are going to write a method to be called validateBoard") that is going to validate whether or not a Tic-Tac-Toe board is possible. Tic-Tac-Toe is played on a 3 by 3 board and players take turns placing either an xor an o on the board. We will assume that in Tic-Tac-Toe, the player placing x will go first and that will go second. Learn more about the game here: https://en.wikipedia.org/wiki/Tic-tac-toe As the player placing x pleces goes first, and play alternates, a valid board is one in which there is either the same number or 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 x game plece in that position "0", representing an o 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 20 array as input and return a boolean value. Details of this method are below. Input The validateBoard method should take as input a 2-dimensional array that holds strings frepresenting the 3 by 3 game board where strings *** and ","denoting the game piece in each location, as described above) Processing The new method will decide whether the incoming 20 array is represents a valid board. A vald board is defined to be a board in which there are either the same number of xas o game pieces or one more than Output of the board is determined to be vald, the method will return a boolean value of true. Otherwise, it will return false Sample input/output: Sample input Sample output "*"), ("x","0","0" true },{"*","0","0") true }. ("x","o","o") false import java.util. public class POD { public static boolean validateBoard(String[][ gameBoard) { boolean validBoard; W/PLEASE START YOUR WORK HERE //PLEASE END YOUR WORK HERE return (validBoard); } public static void main(String[] args) { Instanttate new scanner to read from the console. Scanner in = new Scanner(System.in); int gamePiece; String()D tictactoeBoard new String[3][3]; for (int i 0; i 3; ) { for (int j ; ; 3; 3) { //Read in board //Read in board tictactoeBoard[i][j] = in.next(); //Output board if (j

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!