Class Card

java.lang.Object
  extended by Card
All Implemented Interfaces:
IGuiCard

public class Card
extends java.lang.Object
implements IGuiCard

This class represents a Card object.

Obtaining suit, rank, and many boolean statements is what this class can be used for. Other values can be extended through this class.

When intiated a Card must be passed the suit, either red or black (character sensitive, not case sensitive), and a specific rank.

Author:
Group 6
ab68 Arup Banerjee
rau Robert Buechler
pp25 Patrick Paczkowski
orl Oriana Lisker

Field Summary
static java.lang.String CLUB
           
static java.lang.String DIAMOND
           
static java.lang.String HEART
           
static int MAX_RANK
           
static java.lang.String SPADE
           
 
Fields inherited from interface IGuiCard
CLUBS, DIAMONDS, HEARTS, rankPrefixes, SPADES, suitPrefixes
 
Constructor Summary
Card(java.lang.String suit, int rank)
          Constructs a Card
 
Method Summary
 boolean alternateSuit(Card c)
          Checks to make certain that the card you have and the one you want to compare it to are of alternate suits.
 boolean alternateSuit(java.lang.String suit)
          Checks to make certain that the card you have has an alternate suit to the suit you are comparing it to.
 boolean checkRank(Card c)
          If you want to check a Card Object's rank versus the one you currently have, this is the method you want to use
 boolean checkRank(int r)
          If you want to check a rank versus the one you currently have, this is the method you want to use
 java.lang.String getCardId()
          Converts a card into printable format, by changing the rank of the card into a string, and concatenating it to the suit.
 int getRank()
          Obtains the rank of the Card Object
 java.lang.String getSuit()
          Obtains the suit of the Card Object
 boolean isFaceUp()
          Return true when the card is face up, and false otherwise.
 boolean isOneHigher(Card card)
          Method observes the rank of two cards and compares them.
 boolean isOneLower(Card card)
          Method observes the rank of two cards and compares them.
 boolean isValidRank(int rank)
          Returns a boolean whether or not the rank of a given card is higher than the highest rank we pass in the program
 boolean isValidSuit(java.lang.String suit)
          Checks to see whether or not the card is actually a certain suit
static void main(java.lang.String[] args)
          Main method, tests whether there are bugs in class
 boolean sameSuit(Card c)
          Method used to check whether or not your card has the same suit as the card you are currently comparing it to.
 boolean sameSuit(java.lang.String s)
          Method used to check whether or not your card has the same suit as suit s.
 void setInvisible()
           
 void setVisible()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLUB

public static final java.lang.String CLUB
See Also:
Constant Field Values

DIAMOND

public static final java.lang.String DIAMOND
See Also:
Constant Field Values

HEART

public static final java.lang.String HEART
See Also:
Constant Field Values

SPADE

public static final java.lang.String SPADE
See Also:
Constant Field Values

MAX_RANK

public static final int MAX_RANK
See Also:
Constant Field Values
Constructor Detail

Card

public Card(java.lang.String suit,
            int rank)
Constructs a Card

Parameters:
suit - is the String that is passed, it should be either red or black
rank - is the rank that is passed
Method Detail

isValidSuit

public boolean isValidSuit(java.lang.String suit)
Checks to see whether or not the card is actually a certain suit

Parameters:
suit - a string that is considered a suit
Returns:
true or false

isValidRank

public boolean isValidRank(int rank)
Returns a boolean whether or not the rank of a given card is higher than the highest rank we pass in the program

Parameters:
rank - an int that is passed into the method
Returns:
true if it is a valid rank, false otherwise

getSuit

public java.lang.String getSuit()
Obtains the suit of the Card Object

Returns:
a string, in a standard case would be red or black

getRank

public int getRank()
Obtains the rank of the Card Object

Returns:
an int, the range of this could vary

checkRank

public boolean checkRank(Card c)
If you want to check a Card Object's rank versus the one you currently have, this is the method you want to use

Parameters:
c - is the Card you want to compare to your current Card
Returns:
true if it is the same rank, false otherwise

checkRank

public boolean checkRank(int r)
If you want to check a rank versus the one you currently have, this is the method you want to use

Parameters:
r - is the rank you want to compare to myRank
Returns:
true if it is the same rank, false otherwise

sameSuit

public boolean sameSuit(Card c)
Method used to check whether or not your card has the same suit as the card you are currently comparing it to.

Parameters:
c - is the Card you want to compare to your current Card
Returns:
true if it is the same suit, false otherwise

sameSuit

public boolean sameSuit(java.lang.String s)
Method used to check whether or not your card has the same suit as suit s.

Parameters:
s - is the suit you are comparing against
Returns:
true if it is the same suit, false otherwise

alternateSuit

public boolean alternateSuit(Card c)
Checks to make certain that the card you have and the one you want to compare it to are of alternate suits.

Parameters:
c - is the Card you want to compare to your current Card
Returns:
true if it is of an alternate suit, false otherwise

alternateSuit

public boolean alternateSuit(java.lang.String suit)
Checks to make certain that the card you have has an alternate suit to the suit you are comparing it to.

Parameters:
suit - is the suit you want to compare to your current Card's suit
Returns:
true if alternate suit, false otherwise

isOneLower

public boolean isOneLower(Card card)
Method observes the rank of two cards and compares them. If you want to check if the card you pass in is one lower than your current card

Parameters:
card - is the Card you want to compare to your current Card
Returns:
true if the card is one lower, false otherwise

isOneHigher

public boolean isOneHigher(Card card)
Method observes the rank of two cards and compares them. If you want to check if the card you pass in is one larger than your current card

Parameters:
card - is the Card you want to compare to your current Card
Returns:
true if the card is one higher, false otherwise

getCardId

public java.lang.String getCardId()
Converts a card into printable format, by changing the rank of the card into a string, and concatenating it to the suit.

Specified by:
getCardId in interface IGuiCard
Returns:
String with suit and rank of card, for printing

main

public static void main(java.lang.String[] args)
Main method, tests whether there are bugs in class


isFaceUp

public boolean isFaceUp()
Description copied from interface: IGuiCard
Return true when the card is face up, and false otherwise.

Specified by:
isFaceUp in interface IGuiCard
Returns:
true if and only if the card is face up

setVisible

public void setVisible()

setInvisible

public void setInvisible()