Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 15th, 2012  |  syntax: None  |  size: 1.71 KB  |  hits: 9  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #ifndef CARDDECK_H_INCLUDED
  2. #define CARDDECK_H_INCLUDED
  3. #include <iostream>
  4. #include <string>
  5. #include <cstdlib>
  6. #include <ctime>
  7. #include "PlayingCard.h"
  8.  
  9. const int SIZE_OF_DECK = 52;
  10.  
  11.  
  12. class PlayingCardDeck
  13. {
  14.     PlayingCard* deck[SIZE_OF_DECK];
  15.  
  16.     public:
  17.     //Default Constructor - Creates an unshuffled deck of 52 playing cards. These playing cards are to be implemented as pointers to PlayingCards.
  18.     PlayingCardDeck();
  19.  
  20.     //Overloaded Constructor - shuffles the deck numShuffles times
  21.     PlayingCardDeck(int numShuffles);
  22.  
  23.     //Destructor - When a deck is deleted, the cards remaining in the deck must be deleted.
  24.     ~PlayingCardDeck()
  25.     {
  26.         deleteDeck();
  27.         std::cout << "Deck destroyed.";
  28.     }
  29.  
  30.     //Returns a pointer to a PlayingCard object taken from "the top" of the deck.
  31.     //If there are no more cards in the deck, it returns a null pointer (i.e. 0) and displays a warning.
  32.     PlayingCard* dealCard();
  33.  
  34.     //For deck shuffling.  Cannot shuffle if any cards are missing.
  35.     bool shuffle(int numShuffles);
  36.  
  37.     //Resets the deck to a full deck of 52 unshuffled cards.
  38.     //Remember that when you do this, you must manage the dynamically allocated cards in the deck.
  39.     void reset();
  40.  
  41.     //Returns a string containing all the value and suit codes for the deck.
  42.     //If there have been cards dealt from the deck, those cards will not be displayed.
  43.     std::string getAllCardCodes();
  44.  
  45.     //Returns the number of cards already dealt from the deck.
  46.     int getCountUsed();
  47.  
  48.     //Returns the number of cards remaining in the deck.
  49.     int getCountRemain();
  50.  
  51.     private:
  52.     //Creates an unshuffled deck of 52 unique cards
  53.     void createDeck();
  54.  
  55.     void deleteDeck();
  56.  
  57.  
  58. };
  59.  
  60. #endif // CARDDECK_H_INCLUDED