|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectPile
public class Pile
Pile of sticks for the nim game.
Constructor Summary | |
---|---|
Pile()
Create an empty Pile. |
|
Pile(int number)
Create a Pile with the specified number of sticks. |
Method Summary | |
---|---|
void |
remove(int number)
Remove the specified number of sticks from this Pile. |
void |
setSize(int number)
Set the number of sticks in this Pile. |
int |
size()
Number of sticks in this Pile. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Pile()
Postcondition: this.size() == 0
public Pile(int number)
Precondition: number >= 0
Postcondition: this.size() == number
number
- Initial number of sticks in the pile.Method Detail |
---|
public int size()
Postcondition: this.size() >= 0
public void setSize(int number)
Precondition: number >= 0
Postcondition: this.size() == number
number
- The desired number of sticks in the pile.public void remove(int number)
Precondition: number >= 0
Postcondition: this.size == max(0, old.size - number)
number
- The number of sticks to remove from the pile.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |