Package project2
Class Card
java.lang.Object
project2.Card
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 -
Method Summary
Modifier and TypeMethodDescriptiongetSuit()Returns what's stored in the instance variable suitintgetValue()Returns what's stored in the instance variable valuebooleanisLowerThan(Card otherCard) Returns whether the value is less than the passed in card's valuetoString()Returns a reference to a String containing the state of the Card
-
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
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
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
Returns a reference to a String containing the state of the Card
-