Blackjack Program
Iteration 2
Core Exercise HIT3172
|
#include <deck.h>
Public Member Functions | |
deck () | |
~deck () | |
void | shuffle () |
card * | draw () |
int | get_cards_remaining () |
Private Attributes | |
card * | _cards [DECK_SIZE] |
int | _top_card |
Deck class represents a Deck of 52 Card objects, and is responsible for knowing which card is on top, how many cards are left, and drawing cards from the Deck.
deck::deck | ( | ) |
Initialise the cards array
deck::~deck | ( | ) |
When destroyed, the Deck destructor deletes all card objects it contains
card * deck::draw | ( | ) |
Get the next card off the deck, or NULL if no more cards
int deck::get_cards_remaining | ( | ) |
Get the number of cards remaining
void deck::shuffle | ( | ) |
Shuffles the deck by looping through the cards array and swapping it with another random card lower in the array Goes back to the top of the cards array after completion
|
private |
Array of the card pointers, creates a "has many" relationship with Card. The Deck is composed of many Cards.
|
private |
Field to remember which index to draw from, is incremented each draw call