Class Bag
java.lang.Object
be.belegkarnil.game.board.spectrangle.Bag
- All Implemented Interfaces:
Cloneable
- Author:
- Belegkarnil
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclone()Clone the current bag (note that the random number is different)booleanisEmpty()Know if the bag is emptyprotected voidreset()Reset the bag for another round/game.intsize()Get the number ofPieces the bag has.protected PieceSwap a givenPieceby another from the bagprotected Piecetake()Take onePiecefrom the bagprotected Piece[]take(int amount) Take an amount of Piece from the bag (seetake()
-
Constructor Details
-
Method Details
-
swap
Swap a givenPieceby another from the bag- Parameters:
piece- The Piece to swap- Returns:
- A new
Piecetaken from the bag
-
take
Take an amount of Piece from the bag (seetake() -
reset
protected void reset()Reset the bag for another round/game. All Piece are put into the bag. -
take
Take onePiecefrom the bag- Returns:
- A
Pieceextracted from the bag
-
size
public int size()Get the number ofPieces the bag has.- Returns:
- The number of
Pieces that are in the bag
-
isEmpty
public boolean isEmpty()Know if the bag is empty- Returns:
- true iff the bag contains no
Piece
-
clone
Clone the current bag (note that the random number is different)- Overrides:
clonein classObject- Returns:
- a clone of the bag state
- Throws:
CloneNotSupportedException
-