Class Card


public class Card
extends Object
Card.java Card represents a playing card.
  • Constructor Summary

    Constructors 
    Constructor Description
    Card​(String cardRank, String cardSuit, int cardPointValue)
    Creates a new Card instance.
  • Method Summary

    Modifier and Type Method Description
    boolean matches​(Card otherCard)
    Compare this card with the argument.
    int pointValue()
    Accesses this Card's point value.
    String rank()
    Accesses this Card's rank.
    String suit()
    Accesses this Card's suit.
    String toString()
    Converts the rank, suit, and point value into a string in the format "[Rank] of [Suit] (point value = [PointValue])".

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Card

      public Card​(String cardRank, String cardSuit, int cardPointValue)
      Creates a new Card instance.
      Parameters:
      cardRank - a String value containing the rank of the card
      cardSuit - a String value containing the suit of the card
      cardPointValue - an int value containing the point value of the card
  • Method Details

    • suit

      public String suit()
      Accesses this Card's suit.
      Returns:
      this Card's suit.
    • rank

      public String rank()
      Accesses this Card's rank.
      Returns:
      this Card's rank.
    • pointValue

      public int pointValue()
      Accesses this Card's point value.
      Returns:
      this Card's point value.
    • matches

      public boolean matches​(Card otherCard)
      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

      public String 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 a Deck in an easily readable format or performing other similar functions.
      Overrides:
      toString in class Object
      Returns:
      a String containing the rank, suit, and point value of the card.