DisplayCards and DisplayESP Func.. Helppp

I know you guys must be sick of me by now lol SO this is what is happening I just ran it, got no matches at all. My out put is this:



I guessed green circle, purple circle red circle blue circle and orange circle.



None of them matched.



Under players choice it shows:



green square

orange square

red square

blue square

purple square



Then proceeds to tell me I have level 2 ESP with no matches. Hmmm...



Edit: I ran it again, had one match of orange triangle



The players choice had all different combos than what I selected, and did not have my match in there. There must be something wrong with my switch statement for displaycards?

ANy ideas?

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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
  #include <iostream>
#include <ctime>
#include <cstdlib>
#include <string>


using namespace std;


void DisplayInstructions ( );  
void GenerateCorrectCards (int *);  
int GetGuess ( );  
bool  CheckMatch (int , int *); 
void DisplayCards (int *, int *); 
void DisplayESP (int); 



int main()
{
	
	int generatedCards[5];

	int const CARDS =18;
	

	int user[5];
	int theuser;
	int i;
	
	
const char *deck [CARDS]={"red circle","red square","red triangle","blue circle","blue square",
	 "blue triangle","yellow circle","yellow square","yellow triangle","orange circle",
	 "orange square" ,"orange triangle","purple circle","purple square",
     "purple triangle","green circle","green square","green triangle"};
	
	
	srand ( time(NULL) );//Seeds the random generator once at the beginning
	
	
	DisplayInstructions();
	cout<<"\n";
		
   
	GenerateCorrectCards (generatedCards);//generates the computers cards

	for ( i=0; i<5; i++){

         *(user + i) = theuser=GetGuess(); 
       //  cout<<"playerarray (in main) "<<*(user+i)<<endl;
         CheckMatch (i,generatedCards);
         

         
//int currentGuess = GetGuess();        
////check if currentGuess is a duplicate before updating user array
//
////if not duplicate, check if it matches computer hand
//bool match = CheckMatch (i, generatedCards);
continue;
          
}

 cout<<"Player's Choice "<< "   " << "Computer's Choice "<<"\n";
     cout<<"*******************************************"<<"\n";
    for (i=0; i < 5; i++)
     {   
          

         DisplayCards((user+i),(generatedCards+i));
char userinput;
//	         do{
//	         
//	         	
//
//	cout<<"Do you want to play another round?Enter q to quit,y to keep playing.";
//	cin>>userinput;
//	
//	while(userinput=='Q' , userinput == 'Y' || userinput == 'q', userinput=='Y' || userinput=='y');
//	         
//			 if ( userinput= 'Y' || 'y')
//			 continue;
//		else(userinput=='Q'||'q');
//			break;
//}
	 
	 

        
}

DisplayESP(theuser);

	system ("pause");
	
	
        
	

}
void DisplayInstructions()
{
	
	cout <<	"The computer will generate a deck of 18 cards.\n"
		 << "There are 3 shapes: Circle, square, and triangle.\n"
		 << "There are 6 colors: Red, blue, yellow, orange, purple, and green.\n"
		 << "Pick a shape and then a color.\n"
		 << "Do this 5 times and see if your predictions match what the computer picked,\n checking your ESP level!\n";
	
}



void GenerateCorrectCards(int *generatedCards)
{
	
	int i;
    int selectedInt;
    int alreadySelect = 0;
    int successfulSelections = 0;
    
    while (successfulSelections < 5) {
        selectedInt = (rand() % 18) + 1;				//mod for the deck of 18

        if (successfulSelections==0) {
            *(generatedCards)=selectedInt;
        }
 
        for (int i=0;i<successfulSelections;i++) {			//checking for dup
            if (*(generatedCards+i)==selectedInt) {
                alreadySelect=1;
                break;
            } else {
                alreadySelect=0;

                *(generatedCards+successfulSelections)=selectedInt;
            }
        }

        if (alreadySelect==0) {
            successfulSelections++;
        }
    }
}
    
    
    
	


int GetGuess ( )
{
	int const CARDS=18;
	std::string deck [CARDS]={"red circle","red square","red triangle","blue circle","blue square",
	 "blue triangle","yellow circle","yellow square","yellow triangle","orange circle",
	 "orange square" ,"orange triangle","purple circle","purple square",
     "purple triangle","green circle","green square","green triangle"};
     


std::string to_lower( std::string str ); // make everything lower case

    	std::string color,shape,combo,userSelect;
    	
    	
    	cout<<"Please choose a card with a color first, and then a shape.";
	cin>>color>>shape;
	combo= color + " " +shape;
userSelect=combo;
	
	
  if (userSelect=="red circle")
  		return 1;
  	else if	(userSelect=="red triangle")
  		return 2;
  	else if(userSelect=="red square")
  		return 3;
  	else if(userSelect=="blue circle")
  	
  	return 4;
  	else if (userSelect=="blue triangle")
  	
  	return 5;
  	else if(userSelect=="blue square")
  	
  	return 6;
  	else if(userSelect=="yellow circle")
  	
  	return 7;
  	else if(userSelect=="yellow triangle")
  	
  	return 8;
  	else if(userSelect=="yellow square")
  	
  	return 9;
  	else if (userSelect=="orange circle")
  	
  	return 10;
  	else if (userSelect=="orange triangle")
  	
  	return 11;
  	else if(userSelect=="orange square")
  	
  	return 12;
  	else if (userSelect=="purple circle")
  	
  	return 13;
  	else if (userSelect=="purple triangle")
  	
  	return 14;
  	else if (userSelect=="purple square")
  	
  	return 15;
  	else if(userSelect=="green circle")
  	
  	return 16;
  	else if ( 	userSelect=="green triangle")
 
  	return 17;
  	else if  (userSelect=="green square")
  	
  	return 18;
  	
  	cout<<"Too many invalid guesses.";
  	return -1;
  	
  	
  	
  

    }
    bool  CheckMatch (int theuser, int *generatedCards)
    {
    	
    	for (int i=0;i<5;i++) {
        if (*(generatedCards+i)==theuser) {
            cout << "Your card matches!" << "\n";
            i++;
            return true;
           
    
        }
    }
    cout << "Sorry, your card does not match." << "\n";
    return false;
}
    	
void DisplayCards (int *user, int *generatedCards)
    	{
    	
//DisplayCards is passed the computer’s and the player’s card arrays. 
//It displays the two sets of cards side by side, by color and shape, not by integer! Has no cin's.
//
//Hint:  Use the card mapping array to look up the integer and get the string representing the card.
switch (*(user))
	{
		case 1:
			cout << "red circle"<<endl;
			break;
		case 2:
			cout<< "red square"<<endl;
			break;
		case 3:
			cout << "red triangle" <<endl;
			break;
		case 4:
			cout << "blue circle" <<endl;
			break;
		case 5:
			cout << "blue square" <<endl;
			break;
		case 6:
			cout << "blue triangle" <<endl;
			break;
		case 7:
			cout << "yellow circle"<<endl;
			break;
		case 8:
			cout << "yellow square" <<endl;
			break;
		case 9:
			cout << "yellow triangle" <<endl;
			break;
		case 10:
			cout << "purple circle" <<endl;
			break;
		case 11:
			cout << "purple square" <<endl;
			break;
		case 12:
			cout << "purple triangle" <<endl;
			break;
		case 13:
			cout << "orange circle" <<endl;
			break;
		case 14:
			cout << "orange square"<<endl;
			break;
		case 15:
			cout << "orange triangle" <<endl;
			break;
		case 16:
			cout << "green circle" <<endl;
			break;
		case 17:
			cout << "green square" <<endl;
			break;
		case 18:
			cout << "green triangle" <<endl;
			break;
		
			
	}
}
    		
    void DisplayESP (int theuser) {




if (theuser==0)
	cout<<"Level 1: Don't ever go to the casino!";
	else if(theuser==1||2)
	cout<<"Level 2: Some ESP, slot machines may be best.";
else if (theuser==3||4)
	cout<<"Level 3: Lots of ESP.  Go play the Powerball!";
else if (theuser==5)
		cout<<"You are a psychic! You must go to the casinos and become rich!";
	
	
	
	
	
//switch(theuser){
//
//
//case 0:
//	if(theuser==0)
//	cout<<"Level 1: Don't ever go to the casino's!";
//	break;
//case 1:
//		if(theuser==1 || 2)
//		cout<<"Level 2: Some ESP, slot machines may be best.";
//		break;
//case 2:
//			if (theuser==3||4)
//			cout<<"Level 3: Lots of ESP.  Go play the Powerball!";
//			break;
//case 3:
//			if (theuser==5)
//			cout<<"You are a psychic! You must go to the casinos and become rich!";
//			break;
}
//	0 matches:  “Level 1: No ESP at all!”
//	1-2 matches:  “Level 2: Some ESP, keep working on it!”
//	3-4 matches:  “Level 3: Lots of ESP, try Powerball!”
//	   5 matches:  “Level 4: ESP expert! Host a TV show!”

	
	
	
	
	
//DisplayESP is passed the number of matches.  It displays the appropriate ESP Level message. Has no cin's.
//		
    		
    
    	
    

So i have declared this as a global

1
2
3
4
std::string  CARDS[19]={"nothing","red circle","red square","red triangle","blue circle","blue square",
	 "blue triangle","yellow circle","yellow square","yellow triangle","orange circle",
	 "orange square" ,"orange triangle","purple circle","purple square",
     "purple triangle","green circle","green square","green triangle"};


In the hint for display esp, she says

Hint: Use the card mapping array to look up the integer and get the string representing the card.

Anybody have a clue to what she is talking about? God my professor being out for 3 weeks really screwed me on this program.
Topic archived. No new replies allowed.