Enum Class Pip

java.lang.Object
java.lang.Enum<Pip>
me.ramendev.expokert.Pip
All Implemented Interfaces:
Serializable, Comparable<Pip>, java.lang.constant.Constable

public enum Pip extends Enum<Pip>
The pip of a Card, or a card's value. It is notable that the term "value" might not be reflected throughout this enum's usages, as different games might consider the pip to be comparable, and implement an ordering of pips, or not at all. By default, this enum is ordered as TWO to ACE, in ascending order.
See Also:
API Note:
To get the so-called "value" of a card, use getValue(), as in several games, the value is often more meaningful than the Enum.ordinal(), although getValue() is equivalent to ordinal() + 2.
Implementation Note:
Some methods in this enum that concern the order of pips use Enum.ordinal() in their implementation. The implementation of the enum here declares TWO first and ACE last, as it is regarded as the most common ordering of pips, though that is not to say that some variants use alternate or no orderings at all.
  • Nested Class Summary

    Nested classes/interfaces inherited from class java.lang.Enum

    Enum.EnumDesc<E extends Enum<E>>
  • Enum Constant Summary

    Enum Constants
    Enum Constant
    Description
    The Ace pip, or fourteen pips by default, and in some scenarios, only worth one pip and is the smallest of the bunch.
    Eight pips.
    Five pips.
    Four pips.
    The Jack pip, or eleven pips.
    The King pip, or thirteen pips.
    Nine pips.
    The Queen pip, or twelve pips.
    Seven pips.
    Six pips.
    Ten pips.
    Three pips.
    Two pips by default, but in some variants, two is the largest pip.
    The wildcard pip.
  • Method Summary

    Modifier and Type
    Method
    Description
    static Pip
    from(char character)
    Returns the pip that is notated with the provided character.
    final char
    Trivial getter of the character field.
    final int
    Gets the numerical value of the pip.
    final boolean
    Checks if the given pip is directly next to the given pip in the default pip order.
    static Pip
    Returns the enum constant of this class with the specified name.
    static Pip[]
    Returns an array containing the constants of this enum class, in the order they are declared.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • TWO

      public static final Pip TWO
      Two pips by default, but in some variants, two is the largest pip.
    • THREE

      public static final Pip THREE
      Three pips.
    • FOUR

      public static final Pip FOUR
      Four pips.
    • FIVE

      public static final Pip FIVE
      Five pips.
    • SIX

      public static final Pip SIX
      Six pips.
    • SEVEN

      public static final Pip SEVEN
      Seven pips.
    • EIGHT

      public static final Pip EIGHT
      Eight pips.
    • NINE

      public static final Pip NINE
      Nine pips.
    • TEN

      public static final Pip TEN
      Ten pips.
    • JACK

      public static final Pip JACK
      The Jack pip, or eleven pips.
    • QUEEN

      public static final Pip QUEEN
      The Queen pip, or twelve pips.
    • KING

      public static final Pip KING
      The King pip, or thirteen pips.
    • ACE

      public static final Pip ACE
      The Ace pip, or fourteen pips by default, and in some scenarios, only worth one pip and is the smallest of the bunch.
    • WILD

      public static final Pip WILD
      The wildcard pip. Its value always depends on the circumstances of a particular card game.
  • Method Details

    • values

      public static Pip[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static Pip valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • from

      public static Pip from(char character)
      Returns the pip that is notated with the provided character.
      Parameters:
      character - The character of the pip to be returned.
      Returns:
      The pip with the provided character.
    • getCharacter

      public final char getCharacter()
      Trivial getter of the character field.
      Returns:
      The character of the pip.
    • getValue

      public final int getValue()
      Gets the numerical value of the pip. "Value" in this case often means a numerical value, used in some games, and not necessarily the pip's value itself. By default, this method returns ordinal() + 2, which assumes that TWO is the smallest and ACE is the largest.
      Returns:
      The "value" of the pip.
      Implementation Note:
      It is recommended that you never use this method with the WILD pip, as per the enum's documentation.
    • isNextTo

      public final boolean isNextTo(Pip pip)
      Checks if the given pip is directly next to the given pip in the default pip order. It is universal that TWO and ACE is "next to each other", and the WILD is next to nothing.

      Formally, this method checks if:
      Math.abs(this.ordinal() - pip.ordinal()) == 1.

      Parameters:
      pip - The other pip to check against.
      Returns:
      Whether the two pips are next to each other.