I am attempting the Rock Paper Scissors Lizard Spock program and believe I have everything working correctly except I cant seem to get BOOL to work are there any good resources for describing BOOL and its use.
Thanks for the reply. I have been trying to figure out how to make the determineWinner a bool return but am not sure if I am misplacing it or just completely getting it wrong.
If I should not call main () to restart after a draw would having a return false restart the game and a return true end it? Again thanks for any assistance.
I have been working on your program on my lunch hour and found some ??? that maybe the reason your program does not close after 1st use.
1.-When using While loops make sure you really need it. If while is not really needed sometimes is better to use if statements when running something once.
2.- On line 11 you have a variable names 'EXIT' that has never been used in your program.
3.-userChoice = getUserChoice(); may not be needed since you are running the program once.
4.-Do you really need a while loop on main()?
5.-do you really need to return a value after each function?
Remember that you are only running the program once, and you do not what to repeat anything while the program runs. Except in special cases. Hope this helps. Good and fun program! =)
if (user == ROCK)
{ if (computer == SCISSORS)
{ cout << "\nYou win! Rock breaks Scissors.\n" << endl;
returntrue; // winner
}
if (computer == PAPER)
{ cout << "\nYou lose! Paper covers Rock. \n" << endl;
returnfalse;
}
if (computer == LIZARD)
{ cout << "\nYou win! Rock crushes Lizard. \n" << endl;
returntrue;
}
if (computer == SPOCK)
{ cout << "\nYou lose! Spock vaporizes Rock. \n" << endl;
returnfalse;
}
} // end user == ROCK
Ditto for each of the other user selections.
Line 39: It's a poor practice to bury a call to srand(). srand() should be called ONCE at the beginning of main.
Lines 77-81: You may want to move your check for a tie out of determineWinner(). As written, determineWinner() is really a tri-state function (win, lose, tie).
Lines 6-11: You may want to look into enums for these values.