Class TicTacToeimport java.util.*;/*** A class modelling a tic-tac-toe (noughts

Class TicTacToeimport java.util.*;/*** A class modelling a tic-tac-toe (noughts and crosses, Xs and Os) game.** @author Lynn Marshall* @version November 8, 2012*/public class TicTacToe{public static final String PLAYER_X = “X”; // player using “X”public static final String PLAYER_O = “O”; // player using “O”public static final String EMPTY = ” “; // empty cellpublic static final String TIE = “T”; // game ended in a tieprivate String player; // current player (PLAYER_X or PLAYER_O)private String winner; // winner: PLAYER_X, PLAYER_O, TIE, EMPTY = in progressprivate int numFreeSquares; // number of squares still freeprivate String board[][]; // 3×3 array representing the board/*** Constructs a new Tic-Tac-Toe board.*/public TicTacToe(){board = new String[3][3];}/*** Sets everything up for a new game. Marks all squares in the Tic Tac Toe board as empty,* and indicates no winner yet, 9 free squares and the current player is player X.*/private void clearBoard(){for (int i = 0; i < 3; i++) {for (int j = 0; j =0 && row=0 && col4) return false;// Note: We don’t need to check all rows, columns, and diagonals, only those// that contain the latest filled square. We know that we have a winner// if all 3 squares are the same, as they can’t all be blank (as the latest// filled square is one of them).// check row “row”if ( board[row][0].equals(board[row][1]) &&board[row][0].equals(board[row][2]) ) return true;// check column “col”if ( board[0][col].equals(board[1][col]) &&board[0][col].equals(board[2][col]) ) return true;// if row=col check one diagonalif (row==col)if ( board[0][0].equals(board[1][1]) &&board[0][0].equals(board[2][2]) ) return true;// if row=2-col check other diagonalif (row==2-col)if ( board[0][2].equals(board[1][1]) &&board[0][2].equals(board[2][0]) ) return true;// no winner yetreturn false;}/*** Prints the board to standard out using toString().*/public void print(){// something needs to be added here}/*** Returns a string representing the current state of the game. This should look like* a regular tic tac toe board, and be followed by a message if the game is over that says* who won (or indicates a tie).** @return String representing the tic tac toe game state*/public String toString(){return “”; // this needs to be updated}}Class TicTacToeFrameimport java.util.*;import java.awt.*;import java.awt.event.*;import javax.swing.*;/*** A class modelling a tic-tac-toe (noughts and crosses, Xs and Os) game in a very* simple GUI window.** @author Lynn Marshall* @version November 8, 2012*/public class TicTacToeFrame extends TicTacToe{private JTextArea status; // text area to print game status/*** Constructs a new Tic-Tac-Toe board and sets up the basic* JFrame containing a JTextArea in a JScrollPane GUI.*/public TicTacToeFrame(){// add the necessary code here}/*** Prints the board to the GUI using toString().*/public void print(){// add code here}}

The post Class TicTacToeimport java.util.*;/*** A class modelling a tic-tac-toe (noughts appeared first on graduate paper help.

Save your time - order a paper!

Get your paper written from scratch within the tight deadline. Our service is a reliable solution to all your troubles. Place an order on any task and we will take care of it. You won’t have to worry about the quality and deadlines

Order Paper Now
 

"Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!"