Question
(c++please,thank you!!)You'll implement is the Card class, which represents a single playing card: class Card { private: int rank; // Should be in the range
(c++please,thank you!!)You'll implement is the Card class, which represents a single playing card:
class Card { private: int rank; // Should be in the range 0-12. int suit; // Should be in the range 0-3. public: // constructors, destructor, accessors, and mutators };
You'll need to implement the needed constructors, destructors, accessor functions, and mutator methods. To do this, think carefully about what operations (if any) youll need to perform on an individual card and what information youll need to be able to get from the card. Put the definition for this class in card.hpp and the implementation in card.cpp.
Once you have a class to represent a single card, you can implement your class to represent a whole deck of 52 cards:
class Deck { private: Card cards[52]; int n_cards; // Number of cards remaining in the deck. public: // constructors, destructor, accessors, and mutators };
Again, in addition to the attributes outlined above, youll need to implement any needed constructors, destructors, accessor, and mutator methods. Again, think about what operations need to be performed on a deck of cards. For shuffling, youll want to use C++s rand() function. Put the definition for this class in deck.hpp and the implementation in deck.cpp.
Now that you have classes to represent cards and a deck, you should be able to implement the class to represent a players hand of cards:
class Hand { private: Card* cards; int n_cards; // Number of cards in the hand. public: // constructors, destructor, accessors, and mutators };
When writing the methods for this class, make sure you write a method to print the hand out to std::cout. Put the definition for this class in hand.hpp and the implementation in hand.cpp.
In order to test your classes, write a small program that uses them to do the following things:
Initializes a new deck of 52 cards.
Shuffles that deck.
Deals a hand of 7 cards.
Prints the contents of that hand to the console, and put this program in deal_hand.cpp.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started