|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.Observable
checkers.model.CheckersGame
public class CheckersGame
This class is a part of the main functionality of the checkers game. Its functions include knowing whose turn it is, remembering multiple jumps, relaying end of game conditions and ending the game.
Field Summary |
---|
Fields inherited from interface checkers.CheckersConstants |
---|
ACCEPT, BLUE, CLIENTGAME, DRAW, HOST, HOSTGAME, JOIN, KING, LOCAL, LOCALGAME, NUM_SPACES, PLAYER1SET, PLAYER2SET, RESIGN, SINGLE, UPDATE, WHITE |
Constructor Summary | |
---|---|
CheckersGame(Board b)
Constructor Create the driver, which in turn creates the rest of the system. |
Method Summary | |
---|---|
void |
endGame(java.lang.Object msg)
This method ends the checkers game due to whatever reason neccessary ie. |
void |
endInDraw(int playerNum)
This method ends the game in a draw, alerting both players that the draw has taken place |
void |
endInQuit(int playerNum)
Ends the game as a result of a player quitting, notifying each player |
void |
endTurn()
This method is called after a move has been checked. |
int |
getCurrentTurn()
|
java.lang.String |
getMessage()
|
int |
getPlayerColor(int playerNumber)
Returns color for player number passed in |
java.lang.String |
getPlayerName(int playerNumber)
Returns the name of player with number passed in |
int |
getPlayerNum()
|
int |
getSelectedIndex()
|
boolean |
isGameActive()
|
void |
offerDraw()
Offer a draw |
void |
selectColors()
This method sets the colors of pieces that each player will be |
boolean |
selectSpace(int space)
Determines if a space is selectable based on whose turn it is. |
void |
setPlayer1Color(int color)
Set the color for a player using the passed in value. |
void |
setPlayerName(int num,
java.lang.String name)
Set the name for the player using the passed in values. |
void |
setPlayerNum(int playerNum)
|
void |
startGame()
This method will start the game play. |
Methods inherited from class java.util.Observable |
---|
addObserver, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CheckersGame(Board b)
Method Detail |
---|
public void endTurn()
color
- The color whose turn it will now bespace
- The space on the board from which a multiple jump has to be
madepublic void endGame(java.lang.Object msg)
message
- the message to send to all players regarding the reason for
ending the gamepublic void endInDraw(int playerNum)
public void endInQuit(int playerNum)
the
- player who quitpublic void selectColors()
public void startGame()
public boolean selectSpace(int space)
space
- the space to select
public void offerDraw()
public java.lang.String getPlayerName(int playerNumber)
playerNumber
- Number of player to get name for
public void setPlayerName(int num, java.lang.String name)
num
- The player's number (1 or 2)name
- The name to assign to the player.public int getPlayerColor(int playerNumber)
playerNumber
- Number of player to get color for
public void setPlayer1Color(int color)
num
- The player's number (1 or 2)color
- The color to assign to the player.public int getCurrentTurn()
public boolean isGameActive()
public java.lang.String getMessage()
public int getSelectedIndex()
public int getPlayerNum()
public void setPlayerNum(int playerNum)
playerNum
- The playerNum to set.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |