studentacct.tictactoe
Class TicTacToeSoln

java.lang.Object
  extended by studentacct.tictactoe.TicTacToeSoln
All Implemented Interfaces:
game.Game

public class TicTacToeSoln
extends java.lang.Object
implements game.Game

This represents the solution to the Tic Tac Toe game and this class is written by the student. Note that it is not necessary to write a constructor - the system-defined default constructor is sufficient.

Author:

Constructor Summary
TicTacToeSoln()
           
 
Method Summary
 java.lang.String getPlayerName()
          Specifies the name of the player playing this game.
 void move(game.GameState state)
          Generates the next move for the game by modifying the game state.
 void setPlayerNum(int playerNum)
          Lets the game know which player number they are (always either 0 or 1).
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TicTacToeSoln

public TicTacToeSoln()
Method Detail

getPlayerName

public java.lang.String getPlayerName()
Specifies the name of the player playing this game. This is the name that will be identified publicly on the web, so this should be unique, friendly and anonymous (or not), as you choose.

Specified by:
getPlayerName in interface game.Game
Returns:
the string specifying the player's name.

setPlayerNum

public void setPlayerNum(int playerNum)
Lets the game know which player number they are (always either 0 or 1). Called once before game play starts. It is your job to remember your player number so that later on when the move() method is called, you will know which kind of piece to play. (Player #0 always plays 'O' and player #1 always plays 'X').

Specified by:
setPlayerNum in interface game.Game
Parameters:
playerNum - The player number (0 or 1).

move

public void move(game.GameState state)
Generates the next move for the game by modifying the game state. Gets called many times by the gaming engine, once every time it is the player's turn. You must play for the player number specified by the setPlayerNum() method. NOTE: The parameter is of type GameState, but in practice, it will always be an instance of a class that implements the TicTacToeStateInterface interface, so you can access the board from the state with these two lines of code:
                TicTacToeStateInterface tttState = (TicTacToeStateInterface)state;
                char[][] board = tttState.getBoard();
                

Specified by:
move in interface game.Game
Parameters:
state - The current game state before this move is played.


Web Accessibility