Class Card
java.lang.Object
Card
public class Card extends Object
Card.java
Card
represents a playing card.-
Constructor Summary
-
Method Summary
Modifier and Type Method Description boolean
matches(Card otherCard)
Compare this card with the argument.int
pointValue()
Accesses thisCard's
point value.String
rank()
Accesses thisCard's
rank.String
suit()
Accesses thisCard's
suit.String
toString()
Converts the rank, suit, and point value into a string in the format "[Rank] of [Suit] (point value = [PointValue])".
-
Constructor Details
-
Card
Creates a newCard
instance.- Parameters:
cardRank
- aString
value containing the rank of the cardcardSuit
- aString
value containing the suit of the cardcardPointValue
- anint
value containing the point value of the card
-
-
Method Details
-
suit
Accesses thisCard's
suit.- Returns:
- this
Card's
suit.
-
rank
Accesses thisCard's
rank.- Returns:
- this
Card's
rank.
-
pointValue
public int pointValue()Accesses thisCard's
point value.- Returns:
- this
Card's
point value.
-
matches
Compare this card with the argument.- Parameters:
otherCard
- the other card to compare to this- Returns:
- true if the rank, suit, and point value of this card are equal to those of the argument; false otherwise.
-
toString
Converts the rank, suit, and point value into a string in the format "[Rank] of [Suit] (point value = [PointValue])". This provides a useful way of printing the contents of aDeck
in an easily readable format or performing other similar functions.
-