Click here to Skip to main content
15,905,612 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am making a Who wants to be a millionaire type of game.

So I have a array with the questions and answers, where:

levels[current_level][x][0] - is the question
levels[current_level][x][1-4] - are the questions
levels[current_level][x][5] is the correct answer

I use to compare one of users choices to the right one:

C#
   string key_pressed = Console.ReadLine().ToUpper();
string resp = levels[current_level][x][5]

if(key_pressed.Equals("A"))
{
if (levels[current_level][x][1].Equals(resp))
{//CORRECT}
else
{//INCORRECT}
}



Now I am trying to make the Audience help, and I need the opposite of:

C#
levels[current_level][x][1].Equals(resp)


So the minority of the "audience" vote for the wrong answers.

Thank you
Posted
Comments
gettgotcha 27-Dec-13 15:50pm    
Sorry did not got the point of "Now I am trying to make the Audience help, and I need the opposite of", as you have four choices so you are going to compare user choice against correct answer; before freezing the answer user has gone for audience poll and audience has given a choice which MAY be the user's choice or other option. So you mean to say user is no longer standing with his first answer as audience choice is different, right?
Member 10490707 27-Dec-13 16:26pm    
My question is to compare string and show the user the ones that are diferent drom original string.
I need the opposite from
`string.Equals()`
gettgotcha 27-Dec-13 16:31pm    
Sorry, I think there is something missing which is not having clear context. If you are looking for opposite of "string.Equals()" then just add a negate symbol before it which is opposite.
Karthik_Mahalingam 2-Jan-14 9:25am    
y cant you use levels[current_level][x][1] == resp ;

1 solution

Why wouldn't you make this simpler by:

C#
string key_pressed = Console.ReadLine().ToUpper();

switch (key_pressed)
{
 case "A":
 case "B":
 case "C":
 case "D":
 if(levels[current_level][x][5] == key_pressed)
 {//CORRECT
 }
 else
 {//INCORRECT
 }
 break;
 case "1":
 break;
 case "2":
 default:
 break;
}


you won't have to do so many checks
 
Share this answer
 
v2
Comments
Nelek 27-Dec-13 17:55pm    
You have a point, but... what are "1" and "2" needed for?
on the other hand... you have a typo after "1": break: --> break;
bowlturner 2-Jan-14 9:09am    
In a different question he was looking for A-D, 1-4 for answers and 'hints'

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900