Objective: Create a Tic-Tac-Toe program for 2 players that allows the players to play for as many games as they want, keeping track of the board and winners (or ties). The TicTacToe class will implement the game. Include a three-by-three two-dimensional array as a private data member to create the board. All methods must have appropriate javadoc comments.

1) Display the board before each move.
2) Get a move - loop until a valid move
3) Keep track of the number of games won by Player 1, the number of games won by Player 2 and the number of Ties
4) Output the winner after each game
5) Loop until no more games
6) At the end of all the games output the number of games won by player 1, the number of games won by player 2 and the number of ties
Upload the design (algorithm), UML Diagram, class implementation (.java) and main - driver (.java) files.

Algorithm Steps:
1. Show user board
a. If 1st move, board shown as empty.
2. Prompt the user for which box they want as their input
a. Keep track of player 1 or 2 (X or O)
b. Tell user how to enter(rows and columns)
c. Read in their entry into row, column variable
3. Check input
a. Make sure row and column input is valid.(Exists in board)
b. Make sure row and column input in blank.
c. If is valid, go to 4, otherwise repeat 1
4. Place user’s move into the array (on the board)
a. Mark entry row and column with X or O (1 or 0) depending on player
5. Check array (board) for winner or full.
a. Look to see if rows/columns of same values
b. Look to see if all array indices are filled in
6. Once checked, go back to #1 with new player and repeat until checked is valid (win or tie becomes true)
7. If winner or tie, up the variables for number of wins and ties. (keep track of wins and ties)
a. 1= win for player 1, 2 = win for player2, 3= tie

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

import java.util.Scanner;

public class TicTacToe {

private char[][] board; //Board to store game state
private Scanner input;                //Input for users
private int moves, game;                //State of total games

public TicTacToe()
input = new Scanner(;
board = new char[3][3];
moves = 0;
game = 0;

public void runGame()
int p1w = 0, p2w = 0, ties = 0; //Game results
int winner;
System.out.println("Welcome to Tic Tac Toe");
char answer;
resetGame(); //Reset game board and start at game 1
System.out.println("Game: " + game);
displayBoard(); //Display the board
getMove(1); //Get player 1's move
$40.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats