Class Hand

  • All Implemented Interfaces:
    java.lang.Iterable<Tile.TileType>

    public class Hand
    extends java.lang.Object
    implements java.lang.Iterable<Tile.TileType>
    Hand class is list of Tiles. This class will be used to communicate the cards currently placeable to the bot in challenge mode.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      java.util.List<Tile.TileType> hand
      placeable cards
    • Constructor Summary

      Constructors 
      Constructor Description
      Hand()
      Creates a empty hand.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static Hand deserialize​(org.json.JSONArray data)
      deserialize Hand from json
      Tile.TileType get​(int i)
      Gets the Card from the Hand at a given index.
      boolean isEmpty()
      If no card is available.
      java.util.Iterator<Tile.TileType> iterator()
      Iterates over all available Cards on the hand.
      int len()
      Amount of playable cards available.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Field Detail

      • hand

        public java.util.List<Tile.TileType> hand
        placeable cards
    • Constructor Detail

      • Hand

        public Hand()
        Creates a empty hand.
    • Method Detail

      • deserialize

        public static Hand deserialize​(org.json.JSONArray data)
        deserialize Hand from json
        Parameters:
        data - json input
        Returns:
        deserialize hand
      • get

        public Tile.TileType get​(int i)
                          throws java.lang.IndexOutOfBoundsException
        Gets the Card from the Hand at a given index.
        Parameters:
        i - index in the hand
        Returns:
        playable card
        Throws:
        java.lang.IndexOutOfBoundsException - gets thrown if slot is empty / does not exists
      • len

        public int len()
        Amount of playable cards available.
        Returns:
        amount of playable cards
      • isEmpty

        public boolean isEmpty()
        If no card is available.
        Returns:
        whether hand is empty
      • iterator

        public java.util.Iterator<Tile.TileType> iterator()
        Iterates over all available Cards on the hand.
        Specified by:
        iterator in interface java.lang.Iterable<Tile.TileType>
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object