jrummikub.model
Class StoneHeap

java.lang.Object
  extended by jrummikub.model.StoneHeap

public class StoneHeap
extends java.lang.Object

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


Field Summary
(package private)  java.util.List<Stone> heap
           
 
Constructor Summary
StoneHeap()
          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

heap

java.util.List<Stone> heap
Constructor Detail

StoneHeap

public StoneHeap()
Creates 106 Stones according to standard rules

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