package edu.ucsb.cs56.S11.pconrad.lab07; /** * A grid for playing tic tac toe, with numbers as shown here:
 1|2|3 
--+-+--
 4|5|6 
--+-+--
 7|8|9 
@author Phill Conrad @version CS56 lecture notes 02.02.2011 @see TicTacToeGridTest */ public class TicTacToeGrid implements TicTacToeGame { // instance variables private String grid="_ "; private int numMoves=0; private char turn = 'X'; private char winner = ' '; private boolean gameOver = false; /** * Default constructor for objects of class TicTacToeGrid */ public TicTacToeGrid() {} /** Constructor for objects of class TicTacToeGrid that allows creation of games in middle of play. This is mostly for testing. There should be an equal number of Xs and Os (in which case it is Xs turn) or else 1 more X than there are Os (in which case it is Os turn), otherwise IllegalArgumentException("illegal game state") is thrown. @param gameState nine character string with Xs and Os for positions 1-9 */ public TicTacToeGrid(String gameState) { this.setGameState(gameState); } public char getTurn() { // return 'Q'; // stub return turn; } /** @param i is number of square (like telephone pad) @return 'X','O', or ' '--i.e. contents of square i */ public char charAt(int i) { return grid.charAt(i);} /** nonBlankMatch checks spaces i,j,k to see if they all match. i,j,k must be distinct, and strictly increasing (i.e. i