Need help with Card Deck problem!!!

I have a project that I really cannot figure out. It's to simulate a deck of cards and then have it do the following:

1. Add a method to the class CardDeck named randomDraw(). It should return 1 card drawn randomly from the deck. Use this method to simulate the probability of drawing two face cards from a shuffled deck.

2. Add a method to the CardDeck class named isEmpty(). It should return true if the deck is empty and false otherwise. Write a driver to test the new method.

3. Create a program that uses the Card and CardDeck classes to deal a hand of 13 cards and count the value of the hand based on the number of face cards in the hand. Ace = 4, King = 3, Queen = 2, Jack = 1. The program should display the hand that was dealt along with the value of the hand.


Here's what I have so far:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
  #ifndef CARD_H
#define CARD_H

#include<iostream>
using namespace std;

class Card
{
	public:
		Card();
		Card(char aSuit,
			int aRank);
			
		int getRank() const;
		char getSuit() const;
		
		void displayCard (ostream& outStream) const;
		
	private:
		char suit;
		int rank;
};

#endif 


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include "card.h"
#include<cctype>
#include<string>
#include<iostream>
using namespace std;

Card::Card():rank(2), suit('S')
{
}
Card::Card(char ch, int i): rank(i)
{
	suit=toupper(ch);
}

int Card::getRank() const
{
	return rank;
}
char Card::getSuit() const
{
	return suit;
}

void Card::displayCard(ostream& out) const
{
	string suitString;
		switch(suit){
			case 'S':
				suitString = "Spades";
				break;
			case 'H':
				suitString = "Hearts";
				break;
			case 'D':
				suitString = "Diamonds";
				break;
			case 'C':
				suitString = "Clubs";
				break;
			default:
				suitString = "Invalid Suit";
		}
	
	if(rank >= 2 && rank < 11)
	{
		out << rank << " of " << suitString;
	}
	else 
	{
		switch(rank){
			case 11:
				out << "JACK of " << suitString;
				break;
			case 12:
				out << "QUEEN of " << suitString;
				break;
			case 13:
				out << "KING of " << suitString;
				break;
			case 14:
				out << "ACE of " << suitString;
				break;
		}
	}
	return;
}


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#ifndef CARDDECK_H
#define CARDDECK_H

#include "Card.h"
#include<vector>
using namespace std;

class CardDeck
{
	public:
		CardDeck();
		void shuffleDeck();
		Card draw();
	private:
		vector<Card> theDeck;
		vector<Card> deltCards;
};

#endif 


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "carddeck.h"
#include<ctime>
#include<algorithm>
using namespace std;

CardDeck::CardDeck()
{
	for(int i=2; i<15; ++i)
	{
		theDeck.push_back(Card('S',i));
		theDeck.push_back(Card('H',i));
		theDeck.push_back(Card('D',i));
		theDeck.push_back(Card('C',i));
	}
	srand(time(NULL));
}

Card CardDeck::draw()
{
	if(theDeck.empty())
	{
		exit(1);
	}
	Card aCard = theDeck.back(); 
	theDeck.pop_back();
	deltCards.push_back(aCard);
	return(aCard);
}

void CardDeck::shuffleDeck()
{
	for(int i=0; i<deltCards.size(); ++i)
	{
		theDeck.push_back(deltCards[i]);
	}
	deltCards.resize(0);
	random_shuffle(theDeck.begin(), theDeck.end());
}


I would appreciate any help very much, thanks.
Bump
Topic archived. No new replies allowed.