Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class TicTacToeDemo
- {
- public static char[][] board = new char[3][3];
- public static void main(String[] args)
- {
- TicTacToe.newGame();
- for (int i = 0; i < 9; i++)
- {
- if ((i == 0) || (i == 2) || (i == 4) || (i == 6) || (i == 8))
- {
- if (TicTacToe.winner() == false) //if there is not a winner
- {
- TicTacToe.writeBoard(); //print board to screen
- TicTacToe.getMoveX(); //get move from player X
- }
- }
- else
- {
- TicTacToe.writeBoard(); //print board to screen
- TicTacToe.getMoveO(); //get move from player O
- }
- }
- for (int j = 0; j < 3; j++)
- {
- /*checks to see if the board is full*/
- if ((board[j][0] == board[j][1]) && (board[j][0] == board[j][2]))
- {
- if (board[j][0] == '\0') /*if the board is full...*/
- System.out.println("IT IS A DRAW!"); //there is no winner
- TicTacToe.writeBoard(); //print final board
- System.exit(0);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement