Class Player

java.lang.Object
  extended by java.lang.Thread
      extended by Player
All Implemented Interfaces:
Runnable
Direct Known Subclasses:
HumanPlayer, MachinePlayer

public abstract class Player
extends Thread

Superclass for a SimpleNIM game player

Author:
Namita Singla, Robert Cohen

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
protected  SimpleNIM game
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
Player(SimpleNIM game)
          Constructor
 
Method Summary
 Player getNext()
          Get the opponent
abstract  void makeMove()
          Has the player make a move
abstract  void pickSticks(int sticks)
          Pick up the specified number of sticks
 void run()
          Runs the thread for the player
 void setNext(Player p)
          Sets the opponent
 void setPickSticks(int noOfSticks)
          Sets the number of sticks picked
 void turn()
          Has this player take their turn
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

game

protected SimpleNIM game
Constructor Detail

Player

public Player(SimpleNIM game)
Constructor

Parameters:
game - SimpleNIM game
Method Detail

setNext

public void setNext(Player p)
Sets the opponent

Parameters:
p - the opponent

getNext

public Player getNext()
Get the opponent

Returns:
The opponent

turn

public void turn()
Has this player take their turn


makeMove

public abstract void makeMove()
Has the player make a move


run

public void run()
Runs the thread for the player

Specified by:
run in interface Runnable
Overrides:
run in class Thread

pickSticks

public abstract void pickSticks(int sticks)
Pick up the specified number of sticks

Parameters:
sticks - int

setPickSticks

public void setPickSticks(int noOfSticks)
Sets the number of sticks picked

Parameters:
noOfSticks - The number of sticks picked