jrummikub.model
Class StoneHeap

java.lang.Object
  extended by jrummikub.model.StoneHeap
All Implemented Interfaces:
java.io.Serializable

public class StoneHeap
extends java.lang.Object
implements java.io.Serializable

StoneHeap creates all Stones for a game, manages them and allows players to draw one or more random Stones.

See Also:
Serialized Form

Field Summary
private  java.util.Random generator
           
(package private)  java.util.ArrayList<Stone> heap
           
private static long serialVersionUID
           
 
Constructor Summary
StoneHeap(GameSettings gameSettings)
          Creates 106 Stones according to standard rules
 
Method Summary
 Stone drawStone()
          Removes random Stone from the heap and returns it
 java.util.List<Stone> drawStones(int number)
          Removes several Stones from the heap and returns them
 int getSize()
          Get the number of stones left
 void putBack(java.util.Collection<Stone> stones)
          Put stones back on the heap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

heap

java.util.ArrayList<Stone> heap

generator

private java.util.Random generator
Constructor Detail

StoneHeap

public StoneHeap(GameSettings gameSettings)
Creates 106 Stones according to standard rules

Parameters:
gameSettings - (for number of sets/jokers, colors etc.)
Method Detail

drawStone

public Stone drawStone()
Removes random Stone from the heap and returns it

Returns:
the drawn stone

drawStones

public java.util.List<Stone> drawStones(int number)
Removes several Stones from the heap and returns them

Parameters:
number - number of requested Stones
Returns:
list of drawn stones

getSize

public int getSize()
Get the number of stones left

Returns:
number of stones on the heap

putBack

public void putBack(java.util.Collection<Stone> stones)
Put stones back on the heap

Parameters:
stones - collection of stones to put back