a Gary Sibbitts 10 éve
576
Még több ilyen
utilize a sentinel value that when entered exits the loop
ie: using 1,2,3 or r,p,s for throw, use 0 or x as a sentinel to exit
?what do we do with any other keys?
?data validation?
RPSChoice userChoice;
while ( (userChoice = GetUserChoice()) != RPSChoice.exit )
OR
// priming "read"
RPSChoice userChoice = GetUserChoice();
while ( userChoice != RPSChoice.exit )
{
// do stuff
userChoice = GetUserChoice();
}
or
specific continue or not prompt
* input - player's choice
* return the result(win,lose,tie)
* need to know the computer's choice?
* option 1 - use a property
* option 2 - out/ref parameter
RPSChoice computerChoice;
RPSResult rpsResult = rpsGame.Play(playerChoice, out computerChoice);
string txtComputerChoice = computerChoice.ToString();
Describe what the user does and sees from the computer
0) computer displays welcome message
1) play game
1) computer prompts user for a choice
2) user makes choice
3) computer displays the computer's choice
4) display the result