Class Bag

java.lang.Object
  extended by Bag

public class Bag
extends java.lang.Object

A simple stack holding all the Tiles


Field Summary
 java.util.Stack<Tile> Tiles
           
 
Constructor Summary
Bag()
           
Bag(java.util.ArrayList<Tile> tiles)
          Initializes the bag from an ArrayList of Tiles
Bag(Tile[] Tiles)
          Initializes the bag fom an array of Tiles
 
Method Summary
 void addTile(Tile tile)
          Adds a tile to the bag
 void clear()
          Clears all the Tiles from the bag
static Bag createBag()
          Creates the scabble set of Tiles.
 boolean empty()
          Returns true if the bag is empty, otherwise false.
 Tile getTile()
          gets a random Tile
 java.util.ArrayList<Tile> getTiles()
           
 void initTiles(Tile[] Tiles)
          Fills the bag with a new set of Tiles
 void setTiles(java.util.ArrayList<Tile> tiles)
           
 void setTiles(java.util.Stack<Tile> tiles)
           
 void shake()
          Shake the bag!
 Tile swapTile(Tile Tile)
          Put back a Tile, shake the bag, and get a new Tile
 java.lang.String toString()
          Prints the contents of the bag
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

Tiles

public java.util.Stack<Tile> Tiles
Constructor Detail

Bag

public Bag()

Bag

public Bag(Tile[] Tiles)
Initializes the bag fom an array of Tiles


Bag

public Bag(java.util.ArrayList<Tile> tiles)
Initializes the bag from an ArrayList of Tiles

Method Detail

setTiles

public void setTiles(java.util.Stack<Tile> tiles)

setTiles

public void setTiles(java.util.ArrayList<Tile> tiles)

getTiles

public java.util.ArrayList<Tile> getTiles()

shake

public void shake()
Shake the bag!


empty

public boolean empty()
Returns true if the bag is empty, otherwise false.

Returns:

initTiles

public void initTiles(Tile[] Tiles)
Fills the bag with a new set of Tiles

Parameters:
Tiles -

clear

public void clear()
Clears all the Tiles from the bag


getTile

public Tile getTile()
gets a random Tile


addTile

public void addTile(Tile tile)
Adds a tile to the bag


swapTile

public Tile swapTile(Tile Tile)
Put back a Tile, shake the bag, and get a new Tile


createBag

public static Bag createBag()
Creates the scabble set of Tiles. 2 blank tiles (scoring 0 points) 1 point: E ×12, A ×9, I ×9, O ×8, N ×6, R ×6, T ×6, L ×4, S ×4, U ×4 2 points: D ×4, G ×3 3 points: B ×2, C ×2, M ×2, P ×2 4 points: F ×2, H ×2, V ×2, W ×2, Y ×2 5 points: K ×1 8 points: J ×1, X ×1 10 points: Q ×1, Z ×1

Returns:

toString

public java.lang.String toString()
Prints the contents of the bag

Overrides:
toString in class java.lang.Object