Question: change all the items in the two dimensional Array to a blank character, in other words . Afterwards, it will have a print statement to

change all the items in the two dimensional Array to a blank character, in other words . Afterwards, it will have a print statement to let the user know that the board was reset.

public static void drawBoard(char[][] board) { for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) { if (i % 2 == 1) { System.out.print("-"); } else { if (j % 2 == 1) { System.out.print("|"); } else { System.out.print(board[i / 2][j / 2]); } } } System.out.println(); } } public static void resetBoard(char[][]board){ } public static boolean checkWinner(char[][]board){ } public static void checkFullBoard(char[][]board){ }

public static void main(String[] args) { // TODO code application logic here Scanner scan = new Scanner(System.in); char [][] board = {{' ',' ',' '},{' ',' ',' '},{' ',' ',' '}}; drawBoard(board); int row, col; String winner = "Nobody"; while(winner.equals("Nobody")){ System.out.print("Player X choose your spot: "); row = scan.nextInt(); col = scan.nextInt(); while(board[row][col]!= ' '){ System.out.print("Spot taken, please choose again:"); row = scan.nextInt(); col = scan.nextInt(); } board[row][col] = 'X'; drawBoard(board); checkFullBoard(board); if(checkWinner(board)){ winner = "X"; break; } System.out.print("Player O choose your spot: "); row = scan.nextInt(); col = scan.nextInt(); while(board[row][col]!= ' '){ System.out.print("Spot taken, please choose again:"); row = scan.nextInt(); col = scan.nextInt(); } board[row][col] = 'O'; drawBoard(board); checkFullBoard(board); if(checkWinner(board)){ winner = "O"; break; } } System.out.print(winner + " has won the game!"); } }

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!