|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.ObjectSimpleNIM
public class SimpleNIM
The simple NIM game. There are 21 sticks in the pile. On each move, each user take turns picking up 1, 2, or 3 sticks until there are no more sticks left. The one who picks up the last stick loses.
| Constructor Summary | |
|---|---|
SimpleNIM(SimpleNIMGUI simpleNIMGUI)
The constructor. |
|
| Method Summary | |
|---|---|
void |
displayMessage(String msg)
Displays a message |
protected boolean |
gameOver(Player player)
Game Over? |
protected Player |
getCurrentPlayer()
Returns the current player |
protected int |
getSticksLeft()
Returns the number of sticks left in the pile |
void |
pickSticks(int noOfSticks,
Player turn)
Pick up Sticks |
protected void |
setCurrentPlayer(Player player)
Sets the current player |
protected void |
setWhoGoFirst(String whoGoFirst)
Set which player will go first |
void |
start()
Starts the game |
protected void |
updateSticksLeft(int picksticks)
Updates the number of sticks left in the pile. |
protected boolean |
validMove(int numSticks)
Valid move? |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SimpleNIM(SimpleNIMGUI simpleNIMGUI)
simpleNIMGUI - The GUI associated with the game| Method Detail |
|---|
public void start()
protected void setWhoGoFirst(String whoGoFirst)
whoGoFirst - The first playerprotected void updateSticksLeft(int picksticks)
picksticks - No. of sticks pickedprotected boolean gameOver(Player player)
player - The player
protected Player getCurrentPlayer()
protected void setCurrentPlayer(Player player)
player - The playerprotected boolean validMove(int numSticks)
numSticks - The number of sticks picked
protected int getSticksLeft()
public void displayMessage(String msg)
msg - The message
public void pickSticks(int noOfSticks,
Player turn)
noOfSticks - The number of sticks to be picked upturn - The current player
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||