Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- public class CardTester_Qumsieh
- {
- public static void main( String[] args )
- {
- }
- class Card
- {
- int suit;
- int rank;
- int pointValue;
- /**
- * Creates a new <code>Card</code> instance.
- *
- * @param cardRank a <code>String</code> value
- * containing the rank of the card
- * @param cardSuit a <code>String</code> value
- * containing the suit of the card
- * @param cardPointValue an <code>int</code> value
- * containing the point value of the card
- */
- public Card(String cardRank, String cardSuit, int cardPointValue) {
- switch(cardSuit) {
- case("Hearts"): suit = 0;
- case("Diamonds"): suit = 1;
- case("Clubs"): suit = 2;
- case("Spades"): suit = 3;
- }
- pointValue = cardPointValue;
- }
- /**
- * Accesses this <code>Card's</code> suit.
- * @return this <code>Card's</code> suit.
- */
- public String suit() {
- return "" + suit;
- }
- /**
- * Accesses this <code>Card's</code> rank.
- * @return this <code>Card's</code> rank.
- */
- public String rank() {
- return "" + rank;
- }
- /**
- * Accesses this <code>Card's</code> point value.
- * @return this <code>Card's</code> point value.
- */
- public int pointValue() {
- return this.pointValue;
- }
- /** Compare this card with the argument.
- * @param otherCard the other card to compare to this
- * @return true if the rank, suit, and point value of this card
- * are equal to those of the argument;
- * false otherwise.
- */
- public boolean matches(Card otherCard) {
- return (suit == otherCard.suit && rank == otherCard.rank && pointValue == otherCard.pointValue);
- }
- /**
- * 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 a <code>Deck</code> in an easily readable format or performing
- * other similar functions.
- *
- * @return a <code>String</code> containing the rank, suit,
- * and point value of the card.
- */
- @Override
- public String toString() {
- return suit + " of " + rank + "(Point: " + pointValue + ")";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement