Akinator Problem

Hi, my friend wrote this code for his software development class. He sent it to me to help him after he couldn't figure it out. I couldn't either.

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
  #include <iostream>



using namespace std;

enum nameType{SAM, MIKE, JOSH, ASHLEY, CHRIS, EMILY, MATT, JESSICA, HANNAH, BETH, STRANGER};

//function prototypes
void game();
bool validAnswer(char answer);
void convert(nameType);
void gameResult();


//global variables
string saying1 = "Is your character ever outwardly depressed?  ";
string saying2 = "Does your character ever get pushed around? ";
string saying3 = "Does your character wear glasses? ";
string saying4 = "Was your character Class President? ";
string saying5 = "Is your character mentally ill? ";
string saying6 = "Is your character a jock? ";
string saying7 = "Does your character love film? ";
string saying8 = "Is your character in love with Ashley? ";
string saying9 = "Does your character have blonde hair? ";
string saying10 = "Does your character have dark brown hair? ";
string saying11 = "Does your character wear plaid? ";
string saying12 = "Is your character The Psycho? ";
string saying13 = "Does your character use the Spirit Board? ";
string saying14 = "Is your character afraid of isolation? ";
string saying15 = "Does/Can your character ever use a gun of any kind? ";
string saying16 = "Does your character ever have the opportunity to befriend a dog? ";
string saying17 = "Has your character ever dated Emily? ";
string saying18 = "Does your character consider themself to be close friends with Josh? ";
string saying19 = "Does your character terrify others? ";
string saying20 = "Is your character's weapon of choice a flamethrower? ";
string saying21 = "Does your character try to save thw twins? ";

string output1 = "Is your character a pacifist ?  ";
string output2 = "Is your character good under pressure? ";
string output3 = "Was your character one of the first to encounter the Wendigo? ";
string output4 = "Was your character the first to encounter the Wendigo a year after the twins disappeared? ";
string output5 = "Is your character often times mean? ";
string output6 = "Does your character use the Spirit Board? ";
string output7 = "Does your character take long baths? ";
string output8 = "Does your character consider themself to be close friends with Josh? ";
string output9 = "Is your character flirty? ";
string output10 = "Is it likely that your character is the first in the group to die in 2015? ";
string output11 = "It was just a prank, Han! ";
string output12 = "Does your character have black hair? ";
string output13 = "Does your character have blonde hair? ";
string output14 = "Does your character have red hair? ";
string output15 = "Is your character related to Josh? ";
string output16 = "Does your character have a twin sister? ";
string output17 = "Does your character fall off a cliff? ";
string output18 = "Does your character get pranked at the beginning of the story? ";
string output19 = "Does your character go looking for her sister? ";
string output20 = "Does your character eat her sister's corpse out of starvation? ";
string output21 = "Does your character have the option to drop her twin off a cliff to save herself? ";
string output22 = "Was your character distraught enough to go into the woods alone? ";
string output23 = "Does your character crack under pressure? ";


int gameCount;
string str1 = " ";
char choiceGender;
int male;
int female;
int yes;
int no;
string answer;
string response;
int name;
int main()
{
	//variables
	int x = 0;
	game();
	bool validAnswer();
	void game();


	cin >> x;
	return 0;
}//end main
void game()
{
	cout << "Welcome to Until Dawn Character Akinator." << endl;
	cout << "Think of a Until Dawn character and answer the"
	<< "questions according to what the character looks like, " << endl;
	cout << " , their personality, and actions. " << endl;
	cout << "Directions: " << endl;
	cout << "Enter a M or m if your character is a male." << endl;
	cout << "Enter F or f if your character is a female. " << endl;
	cout << "Enter Y or y to answer yes for the question." << endl;
	cout << "Enter N or n to answer no for the question. " << endl;

	cout << "The game is starting now. " << endl;
	cout << "Is your character a male or female?" << endl;

	cin >> answer;

      if(answer == "M"){
            response = "male";
      }
      if(answer == "F"){
            response = "female";
      }
      if(answer == "Y"){
            response = "yes";
      }
      if(answer == "N"){
            response = "no";
      }
	if (response == "male")
	{
	cout << saying1 << endl; //Josh
	cin >> answer;
	}
	if (answer == "yes")
	{
	cout << saying5 << endl;
	cin >> answer;
	}
	if (answer == "yes")
	{
	cout << saying7 << endl;
	cin >> answer;
	}
	if (answer == "yes")
	{
	cout << "Your character is Josh!" << endl;
	}

	cout << saying2 << endl;//Matt
	cin >> answer;

	cout << saying3 << endl;//Chris
	cin >> answer;

	cout << saying4 << endl;//Mike
	cin >> answer;

	cout << saying5 << endl;//Josh
	cin >> answer;

	cout << saying6 << endl;//Matt
	cin >> answer;

	cout << saying7 << endl;//Josh
	cin >> answer;

	cout << saying8 << endl;//Chris
	cin >> answer;

	cout << saying9 << endl;//Chris
	cin >> answer;

	cout << saying10 << endl;//Mike\Josh
	cin >> answer;

	cout << saying11 << endl;//Josh
	cin >> answer;

	cout << saying12 << endl;//Josh
	cin >> answer;

	cout << saying13 << endl;//Josh\Chris
	cin >> answer;

	cout << saying14 << endl;//Josh
	cin >> answer;

	cout << saying15 << endl;//Chris\Mike\Matt
	cin >> answer;

	cout << saying16 << endl; //Mike
	cin >> answer;

	cout << saying17 << endl;//Mike\Matt
	cin >> answer;

	cout << saying18 << endl;//Chris
	cin >> answer;

//IGGY IS THE BEST!!
	cout << saying19 << endl;//Josh\Stranger
	cin >> answer;

	cout << saying20 << endl; //stranger
	cin >> answer;

	cout << saying21 << endl; //Stranger
	cin >> answer;






	if (response == "female")
	{
	cout << output1 << endl;//Sam
	cin >> answer;

	cout << output2 << endl;//Sam\Emily
	cin >> answer;

	cout << output3 << endl;//Hannah\Beth|Jessica
	cin >> answer;

	cout << output4 << endl;//Jessica
	cin >> answer;

	cout << output5 << endl;//Emily
	cin >> answer;

	cout << output6 << endl;//Ashley
	cin >> answer;

	cout << output7 << endl;//Sam
	cin >> answer;

	cout << output8 << endl;//Hannah\Beth\Sam
	cin >> answer;

	cout << output9 << endl;//Jessica
	cin >> answer;

	cout << output10 << endl;//Jessica
	cin >> answer;

	cout << output11 << endl;//Emily
	cin >> answer;

	cout << output12 << endl;//Emily
	cin >> answer;

	cout << output13 << endl;//Sam\Jessica
	cin >> answer;

	cout << output14 << endl;//Ashley
	cin >> answer;

	cout << output15 << endl;//Hannah\Beth
	cin >> answer;

	cout << output16 << endl;//Hannah\Beth
	cin >> answer;

	cout << output17 << endl;//Hannah\Beth
	cin >> answer;

	cout << output18 << endl;//Hannah
	cin >> answer;

	cout << output19 << endl;//Beth
	cin >> answer;

	cout << output20 << endl;//Hannah
	cin >> answer;

	cout << output21 << endl;//Hannah
	cin >> answer;

	cout << output22 << endl;//Hannah
	cin >> answer;


	cout << output23 << endl;//Ashley
	cin >> answer;




	}//end else if
}//end void game
bool validAnswer(char answer)
{
	switch (answer)
	{
	case 'M':
	case 'm':
	case 'F':
	case 'f':
	case 'Y':
	case 'y':
	return true;
	default:
	return false;

	}//end switch answer
	if (answer == 'M' || answer == 'm')
	response = male;
	else if (answer == 'F' || answer == 'f')
	response = female;
	else if (answer == 'Y' || answer == 'y')
	response = yes;
	else if (answer == 'N' || answer == 'n')
	response = no;
}//end validAnswer
void convert()
{
	switch (name)
	{
	case JOSH:
	cout << "Josh";
	break;
	case CHRIS:
	cout << "Chris";
	break;


	}//end switch
}//end void convert 


Basically all of the sayings variables go to the male characters, and the output variables go to the females. When we try to run the program, typing "F" for female will cause C++ to output "saying2", a variable that corresponds to the males. We were just really confused on why it wouldn't work.

Sorry about dumping the entire code but we didn't know which part in specific was the problem.

Thanks,

icabero0225
your brackets are bad

line 115
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
if (response == "male")
	{
	cout << saying1 << endl; //Josh
	cin >> answer;
	}

if (answer == "yes")
	  {
	  cout << saying5 << endl;
	  cin >> answer;
	  }
if (answer == "yes")
	  {
	  cout << saying7 << endl;
	  cin >> answer;
	  }
if (answer == "yes")
	 {
	  cout << "Your character is Josh!" << endl;
	  }

cout << saying2 << endl;//Matt
cin >> answer;


Saying 2 isn't within the male only if statement, along with every other if statement, just fix that.
Topic archived. No new replies allowed.