Class Tile.Bag

java.lang.Object
model.logic.host.data.Tile.Bag
All Implemented Interfaces:
Serializable
Enclosing class:
Tile

public static class Tile.Bag extends Object implements Serializable
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    static Tile.Bag
    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.
    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.
    void
    put(Tile tile)
    The put function adds a tile to the bag.
    int
    The size function returns the number of letters remaining in the bag.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getBag

      public static Tile.Bag 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

      public Tile getRand()
      The getRand function returns a random tile from the bag.
      Returns:
      A random tile from the bag
    • getTile

      public Tile getTile(char letter)
      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

      public void put(Tile tile)
      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