I'm starting to build classes for a c++ card game (poker probably) and I need some help.
I have a Card class, Hand class, and Deck class. The Deck holds a vector of 52 Card* while hands would hold vectors of some other number of Card*. I want it to work so that the Deck holds all the cards in these pointers, and then the hands can just take the pointer as cards are dealt out. However, I want it to work well when a round is over and the deck is reshuffled, like so the hands will automatically clear their vectors (something along those lines). Is this possible to do? Anyone have a good design for a card game that is better?
Just looking for some help to get me started here. If any of that was unclear let me know.
Partial headers of classes
I have a Card class, Hand class, and Deck class. The Deck holds a vector of 52 Card* while hands would hold vectors of some other number of Card*. I want it to work so that the Deck holds all the cards in these pointers, and then the hands can just take the pointer as cards are dealt out. However, I want it to work well when a round is over and the deck is reshuffled, like so the hands will automatically clear their vectors (something along those lines). Is this possible to do? Anyone have a good design for a card game that is better?
Just looking for some help to get me started here. If any of that was unclear let me know.
Partial headers of classes
| Code: |
| class Card
{ Suit suit; int value; std::string name; void setName(); public: Card(Suit s, int v); Card(const Card &c); Card& operator=(const Card &c); Suit getSuit() const; int getValue() const; friend std::ostream& operator<<(std::ostream &out, const Card &c); }; enum Suit { diamond, heart, club, spade }; // unfinished class Deck { std::vector<Card*> cards; public: Deck(); void riffleShuffle(int repeat = 14); friend std::ostream& operator<<(std::ostream &out, const Deck &d); ~Deck(); }; //barely started class Hand { public: }; |
