98.3k views
5 votes
Implement the bolded part in java code for Tic Tac Toe game on a 6x7 board.

Start with a very simple version of the program, for example, a version that only allows two human players to compete. For that purpose, you would just need a method that checks whether a move is possible or not (column already full?) and another method that checks whether the game is over and what the result is. The next step could be the random-style computer player; just use the random number generator instead of the user input. Detail functions:
1. Finish the method to print the board

User Xclusive
by
6.7k points

1 Answer

1 vote

Final answer:

The printBoard method in Java for a Tic Tac Toe game prints out a 6x7 board by iterating through a 2D char array and displaying each element with separators to represent the game state.

Step-by-step explanation:

In creating a simple Java code for a Tic Tac Toe game on a 6x7 board, we start by defining the method for printing the game board. Here's a straightforward way to achieve this:

public static void printBoard(char[][] board) {
for (int row = 0; row < board.length; row++) ");

}

This method, printBoard, iterates through each row and column of the board and prints out the contents, which are stored in a 2D char array. By default, the array can be initialized with spaces ' ' representing empty positions, and player moves can be represented using 'X' for one player and 'O' for the other.

User Jeevamuthu
by
6.5k points