Each instance of this class is a Morph that can be used to play the Tic-Tac-Toe game. The Morph shows the Tic-Tac-Toe board, any X's and O's that have been played, a RESET button, and a QUIT button. The user(s) will place both X's and O's by clicking on board squares; the computer does not participate as a player.
Instance Variables:
squares an Array of 9 integers giving current board state: 0=empty; 1=X; 2=O
whoMovesNext 1=X moves next; 2=O moves next
winningLine an integer, 1..8, telling which winning line; 0=no winner
selectedSquare an integer, 1..11, giving which button has been mouse-down'ed
highlightedSquare an integer, 1..11, telling which button should be highlighted
Class Variables:
XForm a square Form showing the image of an X
OForm a square Form showing the image of an O
HighlightXForm a square Form showing the highlighted image of an X
HighlightOForm a square Form showing the highlighted image of an O
"This method is passed a move to make (1-9). It checks to see if this is a legal move and, if so, updates the data to make that move. It also checks to see if the game is over."
"When the user presses the mouse button, see if it is in a square or one of the buttons. If in a square, check to see if this would be a legal move, and return if not. Highlight the square, by setting 'highlightedSquare' to the button number 1..11 and sending 'self changed'. Also set 'selectedSquare' to this same number, to remember the focus."
"The mouse has moved. If the mouse is now in the 'selectedSquare', set 'highlightedSquare' to that same number. Otherwise, set 'highlightedSquare' to zero."
"When the user releases the mouse button, see if it is in the 'selectedSquare'. If so, make a move to that square, or do the button action, whichever is appropriate."