Class SolitaireCard
- java.lang.Object
-
- SolitaireCard
-
public class SolitaireCard extends java.lang.Object
A card in the Solitaire deck.- Author:
- Stina Bridgeman
-
-
Constructor Summary
Constructors Constructor Description SolitaireCard(int value)
Create a new (non-joker) card with the specified value.SolitaireCard(int value, char joker)
Create a new joker with the specified values.SolitaireCard(java.lang.String str)
Create a card from its string representation.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getValue()
Get the card's value.boolean
isJoker()
Determine if the card is a joker (either A or B).boolean
isJokerA()
Determine if the card is joker A.boolean
isJokerB()
Determine if the card is joker B.java.lang.String
toString()
Get a string representation of the card.
-
-
-
Constructor Detail
-
SolitaireCard
public SolitaireCard(int value, char joker)
Create a new joker with the specified values.- Parameters:
value
- card value (>= 1)joker
- which joker ('A' or 'B')
-
SolitaireCard
public SolitaireCard(int value)
Create a new (non-joker) card with the specified value.- Parameters:
value
- card value (>= 1)
-
SolitaireCard
public SolitaireCard(java.lang.String str)
Create a card from its string representation.- Parameters:
str
- string representation of the card
-
-
Method Detail
-
getValue
public int getValue()
Get the card's value.- Returns:
- the card's value
-
isJokerA
public boolean isJokerA()
Determine if the card is joker A.- Returns:
- true if the card is joker A, false otherwise
-
isJokerB
public boolean isJokerB()
Determine if the card is joker B.- Returns:
- true if the card is joker B, false otherwise
-
isJoker
public boolean isJoker()
Determine if the card is a joker (either A or B).- Returns:
- true if the card is a joker, false otherwise
-
toString
public java.lang.String toString()
Get a string representation of the card. This will be just the card's value (for a non-joker) or the value followed by A or B (for a joker).- Overrides:
toString
in classjava.lang.Object
- Returns:
- string representation of the card
-
-