Class Card

java.lang.Object
me.ramendev.expokert.Card
Direct Known Subclasses:
Wildcard

public class Card extends Object
A playing card. Playing card Wikipedia article. This class only contains the basic information about a playing card, which is its Pip (its value, synonymously) and its Suit.
API Note:
Technically, one could create a Card with the Pip.WILD pip and the Suit.WILD suit, thus not implementing the wildcard Wildcard.getConversions() functionality one would do by instantiating, a Wildcard or its subclass instance. This, obviously, is not recommended.
Implementation Note:
If you want to create a wildcard-kind of card, you should always use the abstract class Wildcard, or one of the wildcard implementations such as Joker.
  • Constructor Details

    • Card

      public Card(Pip pip, Suit suit)
      Creates a card from the given pip and suit.
      Parameters:
      pip - The pip of the card.
      suit - The suit of the card.
      Throws:
      IllegalCardException - When any of the pip or the suit of the card is WILD. It is recommended that you implement a Wildcard, or use one of its subclasses instead, such as Joker.
    • Card

      public Card(String string)
      Creates a card from the given string, which should notate the card's properties.
      Parameters:
      string - The string of this card.
      Throws:
      IllegalCardException - When the string's notation cannot be parsed to a card.
  • Method Details

    • getAllCards

      public static List<Card> getAllCards()
      Gets all the cards that can be created from all of the Pips (except for Pip.WILD), and all of the Suits (except for Suit.WILD)
      Returns:
      The list of all cards.
    • toString

      public String toString()
      Gets the notation form of this card.
      Overrides:
      toString in class Object
      Returns:
      The notation form of the card.