java.lang.Object
cz.matfyz.rudad.joker.card.Card
- All Implemented Interfaces:
AutoCloseable
Represents a card in a deck.
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the Card instance by removing it from the created cards collection.intReturns the ID of the card.static CardgetInstance(int cardId) Returns a Card instance based on the provided card ID.static CardgetInstance(Rank rank, Suit suit) Returns a Card instance based on the provided rank and suit.static CardgetInstance(String cardAlias) Returns a Card instance based on the provided card alias.getRank()Returns the rank of the card.getSuit()Returns the suit of the card.static booleanReturns if the suit emoji should be printed.static voidsetPrintSuitEmojis(boolean printSuitEmojis) Sets if the suit emoji should be printed.toString()Returns the string representation of the card.
-
Method Details
-
getInstance
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
Returns a Card instance based on the provided rank and suit.- Parameters:
rank- the rank of the cardsuit- the suit of the card- Returns:
- the Card instance
- Throws:
IllegalArgumentException- if the rank or suit is invalid
-
getInstance
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
Closes the Card instance by removing it from the created cards collection.- Specified by:
closein interfaceAutoCloseable- Throws:
Exception- if an error occurs during the closing operation
-
getRank
Returns the rank of the card.- Returns:
- the rank
-
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:
trueif the suit emoji should be printed,falseotherwise
-
setPrintSuitEmojis
public static void setPrintSuitEmojis(boolean printSuitEmojis) Sets if the suit emoji should be printed.- Parameters:
printSuitEmojis-trueif the suit emoji should be printed,falseotherwise
-
toString
Returns the string representation of the card.
-