Create a class, PlayingCard Deck, that mimics a deck of cards as discussed in class.
Implementation
The deck will be implemented as an array of pointers to PlayingCard objects. When the deck is created, the array will contain cards in this order:
A-K of D, A-K of C, A-K of H, A-K of S
The deck may be shuffled before any cards are dealt. After any cards are dealt, trying to shuffle the deck will result in a warning.
When a card is dealt from the deck, a pointer to a PlayingCard object is returned from the top of the deck. The array element representing that card will be set to NULL. The index of the current card will be incremented. If the deck runs out of cards, requesting a card will result in returning a null pointer and displaying a warning.
Public method descriptions
PlayingCardDeck();
Default constructor. Creates an unshuffled deck of 52 playing cards. These playing cards are to be implemented as pointers to PlayingCards. Remember, since this uses pointers, the PlayingCard objects are dynamically allocated and must be managed as such.
The unshuffled deck should be in the order of:
AD 2D 3D 4D 5D 6D 7D 8D 9D TD JD QD KD
AC 2C 3C 4C 5C 6C 7C 8C 9C TC JC QC KC
AH 2H 3H 4H 5H 6H 7H 8H 9H TH JH QH KH
AS 2S 3S 4S 5S 6S 7S 8S 9S TS JS QS KS
PlayingCardDeck(int numShuffles);
Overloaded constructor. In addition to what is described for the default constructor, this constructor shuffles the deck numShuffles times.
~PlayingCardDeck();
Destructor. This is necessary because of the dynamic memory allocation. When a deck is deleted, the cards remaining in the deck must be deleted.
PlayingCard* dealCard();
Returns a pointer to a PlayingCard object taken from “the top” of the deck. If there are no more cards in the deck, it returns a null pointer (i.e. 0) and displays a warning.
bool shuffle(int numShuffles);
We will have discussed 2 methods of shuffling the deck in class. These are exchange shuffle and interleave shuffle. You must use one of these two.
Shuffle should only shuffle if no cards have been dealt from the deck. If one or more cards has been dealt, then the function should return false and no shuffling should be done.
void reset();
Resets the deck to a full deck of 52 unshuffled cards. Remember that when you do this, you must manage the dynamically allocated cards in the deck.
string getAllCardCodes();
Returns a string containing all the value and suit codes for the deck. If there have been cards dealt from the deck, those cards will not be displayed. The cards should be displayed with a single space between each card and a line break after the 13th, 26th, 39th, and 52nd cards from the original deck.
As an example, if 5 cards have been dealt from an unshuffled deck, when the string is displayed, it will show the following:
6D 7D 8D 9D TD JD QD KD
AC 2C 3C 4C 5C 6C 7C 8C 9C TC JC QC KC
AH 2H 3H 4H 5H 6H 7H 8H 9H TH JH QH KH
AS 2S 3S 4S 5S 6S 7S 8S 9S TS JS QS KS
int getCountUsed();
Returns the number of cards already dealt from the deck.
int getCountRemain();
Returns the number of cards remaining in the deck.
Upload to moodle
You should use the driver, PlayingCardDriver.cpp, to complete this assignment. Turn in a zipped project file containing PlayingCardDeck.h, PlayingCardDeck.cpp, PlayingCardDeckDriver.cpp, PlayingCardDeck.cbp, PlayingCard.h, and PlayingCard.cpp.
Check before you submit. Get Turnitin Score Report in 15 Minutes.
Don't risk the 'Red' score. Get the exact same Turnitin report your professor uses. Join 50,000+ students who submitted their essays with confidence this semester.
Welcome to our trusted essay writing website with track record among students. We specialize in connecting students in need of high-quality essay assistance with skilled writers who can deliver just that. Explore the ratings of our essay writers and choose the one that best aligns with your requirements. When you rely on our online essay writing service, rest assured that you will receive a top-notch, plagiarism-free A-level paper. Our experienced professionals write each paper from scratch, carefully following your instructions. Request a paper from us and experience 100% originality.


