Blackjack Program  Iteration 2
Core Exercise HIT3172
 All Classes Functions Variables Enumerations Enumerator
Public Member Functions | Private Attributes | List of all members
deck Class Reference

#include <deck.h>

Public Member Functions

 deck ()
 ~deck ()
void shuffle ()
carddraw ()
int get_cards_remaining ()

Private Attributes

card_cards [DECK_SIZE]
int _top_card

Detailed Description

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.

Constructor & Destructor Documentation

deck::deck ( )

Initialise the cards array

deck::~deck ( )

When destroyed, the Deck destructor deletes all card objects it contains

Member Function Documentation

card * deck::draw ( )

Get the next card off the deck, or NULL if no more cards

Returns
pointer to card object
int deck::get_cards_remaining ( )

Get the number of cards remaining

Returns
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

Member Data Documentation

card* deck::_cards[DECK_SIZE]
private

Array of the card pointers, creates a "has many" relationship with Card. The Deck is composed of many Cards.

int deck::_top_card
private

Field to remember which index to draw from, is incremented each draw call


The documentation for this class was generated from the following files: