PanaceaMuffin

Play Again?

Jan 6th, 2012
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. void PlayAgain()
  2. {
  3.     string strRestartChoice;
  4.     bool bValidEntry;
  5.  
  6.     do
  7.     {
  8.         cout << "Would you like to play again? (y/n):";
  9.  
  10.         cin >> strRestartChoice;
  11.  
  12.         if(strRestartChoice.at(0) == 89 || strRestartChoice.at(0) == 121)
  13.         {
  14.             bRestartGame = true;
  15.             bValidEntry = true;
  16.         } else if (strRestartChoice.at(0) == 78 || strRestartChoice.at(0) == 110) {
  17.             bRestartGame = false;
  18.             bValidEntry = true;
  19.         } else {
  20.             bValidEntry = false;
  21.             cout << "Error. Invalid input\n";
  22.         }
  23.  
  24.         getline(cin, strRestartChoice);
  25.  
  26.     } while (!bValidEntry);
  27.  
  28. }
Add Comment
Please, Sign In to add comment