I'm trying to make this rock, paper, scissors game work but I am having trouble getting past the "You have entered line" as it terminates after that.
My professor said my problem is that userChoice is of type char when randNumGenerated is of type int. I tried to convert my r,p,and s values by using the below: char r = 'a'; int a = r;
But got a "redefinition:different basic types" error from the compiler. I'm not sure what to do, as redefining the variables to int was my intention. Am I thinking of this all wrong? Any help would be greatly appreciated !
int main() { char userChoice; int computer; int randNumGenerated = 0; int r = 0; int p = 0; int s = 0; unsigned seed; cout << "Chose either rock, paper, or scissors" << endl; cout << "Let r,p,and s represent rock,paper,and scissors respectively " << endl; cin >> userChoice; cout << "You entered: " << userChoice << endl; cout << " " << endl; seed = time(0); srand(seed); randNumGenerated = rand() % 3; r == 0; p == 1; s == 2; if ((userChoice == 0 && randNumGenerated == 2) || (userChoice == 1 && randNumGenerated == 0) || (userChoice == 2 && randNumGenerated == 1)) { cout << "You win!"; } if ((userChoice == 0 && randNumGenerated == 1) || (userChoice == 1 && randNumGenerated == 2) || (userChoice == 2 && randNumGenerated == 0)) { cout << "You lose!"; } if ((userChoice == 0 && randNumGenerated == 0) || (userChoice == 1 && randNumGenerated == 1) || (userChoice == 2 && randNumGenerated == 2)) { cout << "It's a draw!"; } return 0; }