p2.tictactoe
Class StreamPlayer

java.lang.Object
  extended by p2.tictactoe.InactivePlayer
      extended by p2.tictactoe.StreamPlayer
All Implemented Interfaces:
Player

public class StreamPlayer
extends InactivePlayer

Manage interaction with user. This implementation of Player gets its moved from a BufferedReader. This can either be a wrapper around the standard input stream, or a wrapper around a string representing a test case.

Version:
$Id: StreamPlayer.java,v 1.2 2005/02/25 00:19:19 oscar Exp $
Author:
$Author: oscar $

Field Summary
 
Fields inherited from class p2.tictactoe.InactivePlayer
game_
 
Constructor Summary
StreamPlayer(char mark)
          The normal contructor to use.
StreamPlayer(char mark, java.io.BufferedReader in)
          Constructor to specify an alternative source of moves (e.g., a test case StringReader).
StreamPlayer(char mark, java.lang.String moves)
          Special constructor to make a Player that plays a fixed set of moves from a String.
 
Method Summary
 void move()
          The Player makes a move by reading a line of text from the input stream, and interpreting it using chess notation, i.e., column is 'a' through 'c' and row is '1' through '3'.
 
Methods inherited from class p2.tictactoe.InactivePlayer
isNobody, mark, setGame, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StreamPlayer

public StreamPlayer(char mark,
                    java.io.BufferedReader in)
Constructor to specify an alternative source of moves (e.g., a test case StringReader).


StreamPlayer

public StreamPlayer(char mark)
The normal contructor to use. Just define the mark. The Player will get its input from the standard input stream.


StreamPlayer

public StreamPlayer(char mark,
                    java.lang.String moves)
Special constructor to make a Player that plays a fixed set of moves from a String. Used to define test cases.

Method Detail

move

public void move()
          throws java.io.IOException,
                 InvalidMoveException
The Player makes a move by reading a line of text from the input stream, and interpreting it using chess notation, i.e., column is 'a' through 'c' and row is '1' through '3'. The converted position is used to call BoardGame.move().

Throws:
java.io.IOException
InvalidMoveException
See Also:
GameDriver.playGame(p2.tictactoe.BoardGame)