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 45 46 47 48 49 50 51 52 53 54 55
|
char* Suits[4] = {"s", "c", "d", "h"};//references for enum types
char* Ranks[13] = {"A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"};
enum class SUIT{ Spades, Clubs, Diamonds, Hearts}; //enumerate card suits and ranks so they can be randomly assigned
enum class RANK{ Ace = 1, Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Jack, Queen, King};
class CARD{
public:
SUIT Card_Suit; //suit and rank of card
RANK Card_Rank;
CARD(){} //default constructor
CARD(int Card_Number) //constructor which takes a card number as an argument and assigns the corresponding suit and rank
{
Card_Suit = (SUIT) (Card_Number / 13);
Card_Rank = (RANK) ((Card_Number % 13) + 1);
}
void Print_Card()
{
std::cout << Ranks[((int) Card_Rank) - 1] << Suits[(int) Card_Suit];
}
};
class DECK{
public:
int Cards_Remaining;//indicates how many cards are left in the deck
bool Cards_Dealt[52];//includes information about cards already dealt
DECK();
void Reshuffle(bool *Cards_Dealt);
CARD Deal_Card();
int RNG(int n); //random number generator
int Select_Available_Card(int Card);
};
#define DECKS_USED 4
DECK Deck[DECKS_USED];
class BLACKJACK{
public:
int Cards_Received;
int Current_Total;
bool Bust;
CARD Cards[11];
int Get_Hand_Total(int Cards_Received);
void Get_Player_Decision();
void Get_Dealer_Decision();
bool Decide_If_Winner(const BLACKJACK &Dealer);
};
|