1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
#include <string>
using namespace std;
#include "card.h"
//================================================= static constants
const string Card::CARD_FACES[] = {"2","3","4","5","6","7","8","9","10","J","Q","K","A"};
const string Card::CARD_SUITS[] = {"C","D","H","S"};
//================================================= Constructor
Card::Card()
{
_card = 0;
}
//================================================= Constructor
Card::Card(int card)
{
_card = card;
}
//================================================== getFace
// Action : Returns face value of card.
// Returns : a string representing card face: "A", "2", ETC........
string Card::getFace() const
{
return CARD_FACES[_card%13];
}//end getFace
//================================================== getSuit
// Action : Returns suit of a card value.
// Returns : a string "S" (Spades), "H", (Hearts),"C" (Clubs), or "D" (Diamonds).
string Card::getSuit() const
{
return CARD_SUITS[_card/13];
}//end getSuit
|