java.lang.Object
cz.matfyz.rudad.joker.card.Card
All Implemented Interfaces:
AutoCloseable

public class Card extends Object implements AutoCloseable
Represents a card in a deck.
  • Method Details

    • getInstance

      public static Card getInstance(String cardAlias) throws IllegalArgumentException
      Returns a Card instance based on the provided card alias.
      Parameters:
      cardAlias - the card alias as a two-character string
      Returns:
      the Card instance
      Throws:
      IllegalArgumentException - if the card alias is invalid
    • getInstance

      public static Card getInstance(Rank rank, Suit suit) throws IllegalArgumentException
      Returns a Card instance based on the provided rank and suit.
      Parameters:
      rank - the rank of the card
      suit - the suit of the card
      Returns:
      the Card instance
      Throws:
      IllegalArgumentException - if the rank or suit is invalid
    • getInstance

      public static Card getInstance(int cardId) throws IllegalArgumentException
      Returns a Card instance based on the provided card ID.
      Parameters:
      cardId - the ID of the card
      Returns:
      the Card instance
      Throws:
      IllegalArgumentException - if the card ID is invalid
    • close

      public void close() throws Exception
      Closes the Card instance by removing it from the created cards collection.
      Specified by:
      close in interface AutoCloseable
      Throws:
      Exception - if an error occurs during the closing operation
    • getRank

      public Rank getRank()
      Returns the rank of the card.
      Returns:
      the rank
    • getSuit

      public Suit getSuit()
      Returns the suit of the card.
      Returns:
      the suit
    • getCardId

      public int getCardId()
      Returns the ID of the card.
      Returns:
      the card ID
    • isPrintSuitEmojis

      public static boolean isPrintSuitEmojis()
      Returns if the suit emoji should be printed.
      Returns:
      true if the suit emoji should be printed, false otherwise
    • setPrintSuitEmojis

      public static void setPrintSuitEmojis(boolean printSuitEmojis)
      Sets if the suit emoji should be printed.
      Parameters:
      printSuitEmojis - true if the suit emoji should be printed, false otherwise
    • toString

      public String toString()
      Returns the string representation of the card.
      Overrides:
      toString in class Object
      Returns:
      the string representation