Package me.ramendev.expokert
Enum Class Pip
- All Implemented Interfaces:
Serializable,Comparable<Pip>,java.lang.constant.Constable
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 theEnum.ordinal(), althoughgetValue()is equivalent toordinal() + 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 declaresTWOfirst andACElast, 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 ConstantsEnum ConstantDescriptionThe 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 TypeMethodDescriptionstatic Pipfrom(char character) Returns the pip that is notated with the provided character.final charTrivial getter of thecharacterfield.final intgetValue()Gets the numerical value of the pip.final booleanChecks if the given pip is directly next to the given pip in the default pip order.static PipReturns the enum constant of this class with the specified name.static Pip[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
TWO
Two pips by default, but in some variants, two is the largest pip. -
THREE
Three pips. -
FOUR
Four pips. -
FIVE
Five pips. -
SIX
Six pips. -
SEVEN
Seven pips. -
EIGHT
Eight pips. -
NINE
Nine pips. -
TEN
Ten pips. -
JACK
The Jack pip, or eleven pips. -
QUEEN
The Queen pip, or twelve pips. -
KING
The King pip, or thirteen pips. -
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
The wildcard pip. Its value always depends on the circumstances of a particular card game.
-
-
Method Details
-
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
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 nameNullPointerException- if the argument is null
-
from
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 thecharacterfield.- 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 returnsordinal() + 2, which assumes thatTWOis the smallest andACEis the largest.- Returns:
- The "value" of the pip.
- Implementation Note:
- It is recommended that you never use this method with the
WILDpip, as per the enum's documentation.
-
isNextTo
Checks if the given pip is directly next to the given pip in the default pip order. It is universal thatTWOandACEis "next to each other", and theWILDis 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.
-