Card Games

I wrote a struct for one single card. I am inheriting this struct into my
Deck52 class.
Deck52 is a member of Game HILO class.

Here is my question :
I have a function to reverse the deck, I want to pass the HILO object into this function.
[Inside The Function ]

How can I refer to a single element of that Deck52 array?



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
void Reverse_Deck(Game* x){

// would i refer to the deck52 elements like this??
x->deck52[0]; // for example
}

1.) I am planning for this program to use three different decks, each is a class
of its own. 
2.) Each will have several games for that particular deck of cards. 


a.)   Do you think it would be good style to write each game as a class of its own,
or to write one Game class for a perticular Deck_Size??
( each game using that deck would become a member function) 


I am thinking, each deck should stay a class of its own, and each game using that class 
should be a derived class from that Deck. Is this good??

Thank You everyone ... 

  Put the code you need help with here.
Last edited on
What does "inheriting into" mean?
Show some code.
What is the point of the card class? Is it complex enough to justify its existence? If it had an image/ graphics, maybe. If its just a pair of integers (a 'suit' and a 'value') then not really. Perhaps a deck of cards itself is a low enough level 'thing' to serve as your basis. Depends on what you are doing and what your wants & needs are which way you go. There are at lest 3 sensible designs... 1) a card class where a deck is a container like a <vector>, 2) a deck class that is unaware of 'cards' (implicit, not explicit, cards, in other words), and 3) as you said, card class and deck class all built by you.. I favor 1 and 2 but not 3; 3 is more work than 1 or 2 so it should be the last choice. 1 and 2 depend on what you need done. 1 has a lot going for it, as you can shuffle a vector, etc...

not all card games have 52 sized decks. (jokers, for example, add 2 more, and what about uno?).

you can overload the [] operator of your 'deck' class to refer to one card. We can show you this once you need to see it, we don't have enough code here to fool with it right now. This is just syntax you may not know, nothing special here, focus on design and let the details like this slide for now, knowing it can be done.
Last edited on
Topic archived. No new replies allowed.