Tic Tac Toe Comments at beginning of program stating what it does Comments withi
ID: 3705222 • Letter: T
Question
Tic Tac Toe
Comments at beginning of program stating what it does
Comments within the program
method to create the board
method to put Xs and Os in right place
method to print the board
method to check for winner
loop
correct output
fist task is to create the 'board' with the lines in the right places and the numbers in the right places. This method (we called it createBoard returns the board to main. The next method you need is to print the board. Put these two methods in main. Run your program and make sure you get the right output.
ALSO - and this is REALLY important. I made a mistake last night.
When you first make your board you need to fill it all with spaces BEFORE you put the lines in.
for(int i=0; i<11; i++)
for(int k=0; k<11; k++)
board[i][k]=' '; //there is a single space here
If you are more comfortable putting the {} in the loops, it looks like this:
for(int i=0; i<11; i++)
{for(int k=0; k<11; k++)
{board[i][k]=' '; } //there is a single space here
}
Explanation / Answer
*Store this class in a file name T3Game.java * public class T3Game { char board[]; int size = 3; int remainingPosition = 9; public T3Game() { this.size = size; this.board = new char[size*size]; for(int i = 0; i= size*size) return false; else return true; } private void displayBoard() { for( int i = 0 ; iRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.