java.lang.Object
cz.matfyz.rudad.joker.card.Card
- All Implemented Interfaces:
AutoCloseable
Represents a card in a deck.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes the Card instance by removing it from the created cards collection.int
Returns the ID of the card.static Card
getInstance
(int cardId) Returns a Card instance based on the provided card ID.static Card
getInstance
(Rank rank, Suit suit) Returns a Card instance based on the provided rank and suit.static Card
getInstance
(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 boolean
Returns if the suit emoji should be printed.static void
setPrintSuitEmojis
(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:
close
in 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:
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
Returns the string representation of the card.
-