java.lang.Object
model.logic.host.data.Tile.Bag
- All Implemented Interfaces:
Serializable
- Enclosing class:
Tile
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic Tile.BaggetBag()The getBag function is a static function that returns the single instance of the Bag class.int[]The getQuantities function returns a copy of the remainingLetters array.getRand()The getRand function returns a random tile from the bag.getTile(char letter) The getTile function takes a character as an argument and returns the Tile object associated with that letter.voidThe put function adds a tile to the bag.intsize()The size function returns the number of letters remaining in the bag.
-
Method Details
-
getBag
The getBag function is a static function that returns the single instance of the Bag class. If there is no instance, it creates one and initializes its letterIndexDictionary variable.- Returns:
- A bag object
-
getRand
The getRand function returns a random tile from the bag.- Returns:
- A random tile from the bag
-
getTile
The getTile function takes a character as an argument and returns the Tile object associated with that letter. If there are no more tiles of that type, it returns null.- Parameters:
letter- letter Determine which tile to return- Returns:
- A tile with the given letter
-
put
The put function adds a tile to the bag.- Parameters:
tile- tile Add a tile to the bag
-
size
public int size()The size function returns the number of letters remaining in the bag.- Returns:
- The sum of the remaining letters array
-
getQuantities
public int[] getQuantities()The getQuantities function returns a copy of the remainingLetters array.- Returns:
- A copy of the remaining letters array
-