Hey all! I am a newb and need a little guidance. Quick note to let you know where I'm at: I have done some personal study, and tutorials off and on for a few years and have gotten to the point where I want to hit the programming hard. I did a tutorial for javascript a while back, and it taught me rock, paper, scissors. At the time I modified it to rock, paper, scissors, lizard, spock. Now I have attempted to convert the javascript to C++ here is my attempt.
I have 60 errors most of them being userChoice and computerChoice need to have a bool type or be converted to a bool. The other errors are all my if, else if statements register as "conditional expression of type...is illegal." What do I need to do to get from this to a working script? Also, thank you in advance =D
Your if statements need a double equal sign, not a single one, I can tell you that much, but you are also attempting to use the strings userChoice and computerChoice as integers. I'm not sure where you came up with the idea of lizard and spock, but I get the idea. Use separate integer variables with values 1-5 that determine each string's value, and correct the single equal signs in each if statement, as they will apply that value rather than check for it.
In your code, you've declared computerChoice as a string, but then you try to assign it an integer value: computerChoice = rand() % 5 + 1;
I don't know about Javascript (never coded in it before), but in C++, variables can't change types.
So, you're probably going to want to declare a new (int) variable to hold the random value, and then assign the proper value to computerChoice based on the value of that.
Also, for comparison, you need to use two == signs: if (computerChoice == 1)
What your code is doing right now is assigning the value 1 to computerChoice and then checking if the new value isn't 0 (which of course it's not).
I see, the double = brought me down to 10 errors. I think I understand what you are saying about the integer variables I'll have to look into that a little more. Thank you for the help.
BTW the idea, for lizard and spock i took from The Big Bang Theory