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.
Need Help with Your Essay? Our Experts Are Ready to Assist
Tell us about your assignment and we will find the best writer for your paper
Write My Essay For Me
Struggling with paper writing? Look no further, as you have found the ideal paper writing company! We are a reputable essay writing service that offers high-quality papers at affordable prices. On our user-friendly website, you can request a wide range of assignments. Rest assured that our work is entirely original. Each essay is crafted from scratch, tailored to meet the precise requirements of your assignment. We guarantee that it will successfully pass any plagiarism check.
Get Your Assignments Completed by Expert Writers. Hire Essay Helpers for Any Task
Order essays, term papers, research papers, reaction paper, research proposal, capstone project, discussion, projects, case study, speech/presentation, article, article critique, coursework, book report/review, movie review, annotated bibliography, or another assignment without having to worry about its originality – we offer 100% original content written completely from scratch