Can someone help me...High Card Game

The game is as follows. The program asks the user the seed for random number generation.
Then it fills the card deck and shuffles the deck, just like in the basic level. Then the game starts. Initially, you have $10 dollars. In each round, the program deals one hand to you by drawing a card from the tip of the deck, and shows it to you.
You will place a bet on whether your next hand will be bigger or smaller than this hand. If your bet is correct, you win $10;
otherwise, you lose $10. To place a bet, enter “b” to indicate that you think the next hand will be bigger, and enter “s” to mean otherwise.
The game continues until one of these conditions are met:
(1) Your balance becomes 0. Then the game ends automatically since you are broke.
(2) You choose to leave the game with a positive balance. You can do this by entering “n” as
your bet, and the game will end and your balance will be shown. Note you have to play at least
three hands before you can leave the game.
(3) The entire deck of 52 cards are drawn. The
game automatically ends and your balance is shown as well.
The rules of comparison between cards are simple. If a card’s face, or equivalently value,
is bigger than that of the other card, then this card is bigger. Ace is the smallest, and King is
the biggest face. If the two cards have the same face, then we compare their suits. Suits are
arranged in an alphabetically ascending order. This implies that
Clubs < Diamonds < Hearts < Spades.


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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
#include <iostream> 
#include <cstdlib> 
#include <cstring> 
#include <ctime> 
using namespace std;

class Card
{
public:
	Card();
	void setFace(char *f);
	char *getFace();
	void setSuit(char *s);
	char *getSuit();
	void setValue(int );
	int getValue();
private:
	char *face;
	char *suit;
	int value;	// value depends just on the face 
};

// default constructor 
// pointers should be initialized to NULL, numbers to zero 
Card::Card()
{
	face = NULL;
	suit = NULL;
	value = 0;
}

void Card::setFace(char *f)
{
	face = f;
}

char *Card::getFace()
{
	return face;
}
void Card::setSuit(char *s)
{
	suit = s;
}

char *Card::getSuit()
{
	return suit;
}
void Card::setValue(int v)
{
	value = v;
}

int Card::getValue()
{
	return value;

}



void filldeck(Card *, char[][10], char[][10]);
void shuffle(Card *);
void printdeck(Card *);

const int decksize = 52;

int main()
{
	Card deck[decksize];

	char face[][10] =
	{ "Ace","Deuce", "Three", "Four", "Five",
		"Six", "Seven", "Eight", "Nine", "Ten",
		"Jack", "Queen", "King" };

	char suit[][10] =
	{ "Hearts", "Diamonds", "Clubs", "Spades" };

	int seed;
	cout << "Enter the seed for random number generation: ";
	cin >> seed;
	srand(seed);	// this sets the seed of random number generation 

	filldeck(deck, face, suit);
	shuffle(deck);
	cout << "### High Card Game Begins! ###" << endl;
	int blc = 10;
	char bet;
	if (blc > 0) {
		cout << "Hand 1:" << deck[0].getFace() << " of " << deck[0].getSuit();
		cout << "Your balance is " << blc << " dollars.";
		cout << "Your bet?";
		cin >> bet;
	}
	for (int i = 1;i < 52; i++) {

		if (bet == 'b') {
			cout << endl << "Hand " << i + 1 << ": " << deck[i].getFace() << " of " << deck[i].getSuit();
			if (deck[i].getValue() > deck[i - 1].getValue()) {

				cout << "BIGGER than the previous hand.WIN! ";
				cout << "Your balance is " << blc + 10 << " dollars.";
				cout << "Your bet?";
				cin >> bet;
			}
			else if (deck[i].getValue() < deck[i - 1].getValue()) {
				cout << "SMALLER than the previous hand.LOSE! ";
				cout << "Your balance is " << blc - 10 << " dollars.";
				cout << "Your bet?";
				cin >> bet;
			}
			else if (deck[i].getValue() == deck[i - 1].getValue()) {
				if (deck[i].getSuit() == "Spades") {
					cout << "BIGGER than the previous hand.WIN! ";
					cout << "Your balance is " << blc + 10 << " dollars.";
					cout << "Your bet?";
					cin >> bet;
				}

				else if (deck[i].getSuit() == "Hearts"&& deck[i - 1].getSuit() != "Spades") {
					cout << "BIGGER than the previous hand.WIN! ";
					cout << "Your balance is " << blc + 10 << " dollars.";
					cout << "Your bet?";
					cin >> bet;
				}
				else if (deck[i].getSuit() == "Diamonds"&& deck[i - 1].getSuit() == "Clubs") {
					cout << "BIGGER than the previous hand.WIN! ";
					cout << "Your balance is " << blc + 10 << " dollars.";
					cout << "Your bet?";
					cin >> bet;
				}
				else {
					cout << "SMALLER than the previous hand.LOSE! ";
					cout << "Your balance is " << blc - 10 << " dollars.";
					cout << "Your bet?";
					cin >> bet;
				}
			}
		}
		if (bet = 's') {
			cout << endl << "Hand " << i + 1 << ": " << deck[i].getFace() << " of " << deck[i].getSuit();
			if (deck[i].getValue() < deck[i - 1].getValue()) {

				cout << "SMALLER than the previous hand.WIN! ";
				cout << "Your balance is " << blc + 10 << " dollars.";
				cout << "Your bet?";
				cin >> bet;
			}
			else if (deck[i].getValue() > deck[i - 1].getValue()) {
				cout << "BIGGER than the previous hand.LOSE! ";
				cout << "Your balance is " << blc - 10 << " dollars.";
				cout << "Your bet?";
				cin >> bet;
			}
			else if (deck[i].getValue() == deck[i - 1].getValue()) {
				if (deck[i].getSuit() == "Clubs") {
					cout << "SMALLER than the previous hand.WIN! ";
					cout << "Your balance is " << blc + 10 << " dollars.";
					cout << "Your bet?";
					cin >> bet;
				}

				else if (deck[i].getSuit() == "Diamonds"&& deck[i - 1].getSuit() != "Clubs") {
					cout << "SMALLER than the previous hand.WIN! ";
					cout << "Your balance is " << blc + 10 << " dollars.";
					cout << "Your bet?";
					cin >> bet;
				}
				else if (deck[i].getSuit() == "Hearts"&& deck[i - 1].getSuit() == "Spades") {
					cout << "SMALLER than the previous hand.WIN! ";
					cout << "Your balance is " << blc + 10 << " dollars.";
					cout << "Your bet?";
					cin >> bet;
				}
				else {
					cout << "BIGGER than the previous hand.LOSE! ";
					cout << "Your balance is " << blc - 10 << " dollars.";
					cout << "Your bet?";
					cin >> bet;
				}
			}
		}
		if (blc == 0) {
			cout << endl << "Game ends, you are broke! :("; 
			
		}
		while (bet == 'n') {
			if (i <= 3) {
				cout << "You can't quit now! Your bet? ";
				cin >> bet;
			}
			else if (i > 3) {
				cout << "Game ends, you have " << blc << " dollars. Congratulations!";
			}
		}
		
	}
				   
			
			

	

	return 0;
}

// fill the deck with 52 cards sequentially with the original order in wFace and wSuit 
// that is, the 13 cards should be Ace of Hearts, Deuce of Hearts, ..., King of Hearts 
// the next 13 cards are Ace of Diamonds, ..., King of Diamonds, and so on 
// you also need to set the value for each Card according to its face: Ace has a value of 1, 
// Deuce 2, Three 3, ..., Jack 11, Queen 12, King 13 
void filldeck(Card *wDeck, char wFace[][10], char wSuit[][10])
{
	for (int i = 0; i < decksize; i++)
	{
		wDeck[i].setFace(wFace[i % 13]);
		wDeck[i].setSuit(wSuit[i % 4]);
		wDeck[i].setValue((i % 13) + 1);
	}
}

// for each card of the deck, randomly shuffle it with another in the deck 
void shuffle(Card *wDeck)
{
	for (int i = 0; i < decksize; i++)
	{
		Card temp;
		int j = rand() % decksize;
		// swap cards i and j 
		temp = wDeck[i];
		wDeck[i] = wDeck[j];
		wDeck[j] = temp;

	}
}
// prints the deck sequentially 
void printdeck(Card * wDeck)
{
	for (int i = 0; i < 52; i++)
	{
		cout << wDeck[i].getFace() << " of " << wDeck[i].getSuit();
		cout << endl;
	}
}

Last edited on
What problems are you having with the code?
92 [Error] 'wDeck' was not declared in this scope
how to solve it?
Compiles fine for me.

If you're still having problems, please post the FULL text of the error message.

Compiles fine too for me.
To make it easier say what you can say at the beginning
Topic archived. No new replies allowed.