How to make java TicTacToe table? -
how create 3x3 without changing given method?
i need create 4 methods beside main method, stuck on display board.
do need create variable or represent each number can use update board each time after user enter move?
it's supposed this:
1 2 3
4 5 6
7 8 9
the following main method can't changed.
public class tictactoe { public static void main (string args[]) { char[] board = {'1', '2', '3', '4', '5', '6', '7', '8', '9'}; char move = 'o'; displayboard(board); while (!checkwinner(board, move)){ move = changemove(move); makemove(board, move); displayboard(board); }
from code provided, looks given board
.
it is:
char[] board = {'1', '2', '3', '4', '5', '6', '7', '8', '9'};
what want turn in 3x3 display.
this simple as:
int k =0; char[] board = {'1', '2', '3', '4', '5', '6', '7', '8', '9'}; (int i=1;i<=3;i++) { (int j=1;j<=3;j++) { system.out.print(board[k]); k++; } system.out.println(); }
i think confusing thinking have update tic-tac-toe logic part of problem in display itself.
what should do, when make move, change whatever needs changed in board
array, , can redraw board.
Comments
Post a Comment