Can't figure it out

Hey, I have been around this exercise for hours and the book it comes on has no solutions so I'd be very greatefull if anyone could solve it for me and explain it.

(Card Shuffling and Dealing) Create a program to shuffle and deal a deck of cards. The
program should consist of class Card, class DeckOfCards and a driver program. Class Card should
provide:
a) Data members face and suit of type int.
b) A constructor that receives two ints representing the face and suit and uses them to initialize
the data members.
c) Two static arrays of strings representing the faces and suits.
d) A toString function that returns the Card as a string in the form “face of suit.” You
can use the + operator to concatenate strings.
Class DeckOfCards should contain:
a) A vector of Cards named deck to store the Cards.
b) An integer currentCard representing the next card to deal.
c) A default constructor that initializes the Cards in the deck. The constructor should use
vector function push_back to add each Card to the end of the vector after the Card is
created and initialized. This should be done for each of the 52 Cards in the deck.
d) A shuffle function that shuffles the Cards in the deck. The shuffle algorithm should
iterate through the vector of Cards. For each Card, randomly select another Card in the
deck and swap the two Cards.
e) A dealCard function that returns the next Card object from the deck.
f) A moreCards function that returns a bool value indicating whether there are more Cards
to deal.

Thank you very much for your time. If you can solve this for me you will give me a very big push and by that you'll help me advance into the next chapter, to which I can't go because there is a concept I'm missing.
http://www.cplusplus.com/doc/tutorial/

I am pretty sure the book does not just make you do the problems without teaching you about the concepts.
Last edited on
Of course not. But somethings you can't totally understand. This is what I've managed so far. I can't understand the consctructor and what follows. I'm trying to solve this exercise so I can get a clearly understandment of what's missing in my knowledge base.

http://pastebin.com/pJeXMH0f
Basically what the constructor is doing is asking for two values both of type int. Then in between the brackets {} and the parentheses () it it initializes the face and suit values with the value of f for face and s suit.
I hope this helps. :)


Oh and by the way I am a horrible teacher but Bucky is a much better one so if you need more help.

http://www.youtube.com/watch?v=53VYYMy-LBo&feature=relmfu
Last edited on
That part is the one I made. The problem is on the DeckOfCards constructor. I can't figure out how to set each of the 52 cards of the vector deck to have a specific suit and face every one of them, by using only the constructor of the Card class.

I guess I didn't explain clearly enough. I'm sorry for that.
It is a one to one function. If you line up the cards by suit and rank:

01 --> Ace of Spades
02 --> 2 of Spades
03 --> 3 of Spades
...
10 --> 10 of Spades
11 --> Jack of Spades
12 --> Queen of Spades
13 --> King of Spades
14 --> Ace of Diamonds
15 --> 2 of Diamonds
16 --> 3 of Diamonds
...
Topic archived. No new replies allowed.