|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectjava.lang.Thread
Player
public class Player
This class contains information and methods related to Players and their pieces.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class java.lang.Thread |
|---|
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
| Field Summary | |
|---|---|
protected Board |
b
|
protected Piece[] |
checkers
|
protected java.awt.Color |
color
|
protected int |
direction
|
protected boolean |
hasWon
|
protected boolean |
isMyTurn
|
protected java.lang.String |
name
|
protected Player |
opponent
|
protected int |
playerNumber
|
| Fields inherited from class java.lang.Thread |
|---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
| Constructor Summary | |
|---|---|
Player(int pNum,
int dir,
java.lang.String n,
Board boardRef)
Constructor |
|
Player(int pNum,
int dir,
java.lang.String n,
Player otherPlayer,
Board boardRef)
Constructor |
|
| Method Summary | |
|---|---|
int |
endTurn()
This method ends the current players turn and updates the opponent that it is now their turn. |
int |
getPlayerNumber()
This method gets the number of the player |
boolean |
mayMove(Board b)
This methods determines whether a player has any moves. |
boolean |
playerMustJump(Board b)
This methods determines whether a player has any pieces it must jump. |
boolean |
playerMustJump(Board b,
int chNo)
This methods determines whether a given piece must jump. |
int |
playerType()
|
void |
run()
|
void |
sendMove(int col1,
int row1,
int col2,
int row2)
This method is overridden in the NetPlayer class |
void |
setCheckersArray(Piece[] pieces)
This method sets the checker array to the appropriate piece |
void |
setOpponent(Player otherPlayer)
This method sets the players opponent |
int |
setTurn()
This method returns the interger representing the players number and it calls threads notify. |
void |
waitForTurn(Board b)
|
| 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 |
|---|
protected int direction
protected int playerNumber
protected boolean isMyTurn
protected java.awt.Color color
protected Player opponent
protected Piece[] checkers
protected java.lang.String name
protected boolean hasWon
protected Board b
| Constructor Detail |
|---|
public Player(int pNum,
int dir,
java.lang.String n,
Board boardRef)
pNum - Number of playerdir - Directionn - String for nameboardRef - Board reference
public Player(int pNum,
int dir,
java.lang.String n,
Player otherPlayer,
Board boardRef)
pNum - interger for player numberdir - interger for directionn - String for nameotherPlayer - Player for opponentboardRef - reference to the board| Method Detail |
|---|
public void setOpponent(Player otherPlayer)
otherPlayer - Playerpublic int getPlayerNumber()
public int endTurn()
public int setTurn()
public void sendMove(int col1,
int row1,
int col2,
int row2)
col1 - columnrow1 - rowcol2 - columnrow2 - rowpublic void setCheckersArray(Piece[] pieces)
pieces - Piece class
public boolean playerMustJump(Board b,
int chNo)
b - A reference to the board for determining jump capabilitieschNo - Lets the method which piece to check for jump capabilities
public boolean playerMustJump(Board b)
b - A reference to the board for determining jump capabilities
public boolean mayMove(Board b)
b - A reference to the board for determining jump capabilities
public int playerType()
public void waitForTurn(Board b)
public void run()
run in interface java.lang.Runnablerun in class java.lang.Thread
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||