Package project2

Class Card

java.lang.Object
project2.Card

public class Card extends Object

Title: The Card class

Description: This class will represent a single playing card that has a value between 1 and 13 and a suit (clubs, diamonds, hearts or spades). A card can return its value, suit, point value or reference to a String containing the card's value and suit. It can check to see if two cards have the same value or the same suit.

Author:
NCC CS1 Professors
  • Constructor Summary

    Constructors
    Constructor
    Description
    Instantiates a 7 of diamonds
    Card(int num)
    Instantiates a customized card
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns what's stored in the instance variable suit
    int
    Returns what's stored in the instance variable value
    boolean
    isLowerThan(Card otherCard)
    Returns whether the value is less than the passed in card's value
    Returns a reference to a String containing the state of the Card

    Methods inherited from class java.lang.Object

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

    • Card

      public Card()
      Instantiates a 7 of diamonds
    • Card

      public Card(int num)
      Instantiates a customized card
      Parameters:
      num - A value between 0 and 51
  • Method Details

    • getValue

      public int getValue()
      Returns what's stored in the instance variable value
      Returns:
      the state of the instance variable value
    • getSuit

      public String getSuit()
      Returns what's stored in the instance variable suit
      Returns:
      a reference to a String that contains the state of the instance variable suit
    • isLowerThan

      public boolean isLowerThan(Card otherCard)
      Returns whether the value is less than the passed in card's value
      Parameters:
      otherCard - Card to which this card is to be compared
      Returns:
      whether the value is less than the passed in card's value
    • toString

      public String toString()
      Returns a reference to a String containing the state of the Card
      Overrides:
      toString in class Object
      Returns:
      a reference to a String object that contains the value and the suit of the card