Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. void printIntro();
  6. void printGuessAnswer();
  7. void printBar();
  8. void playGame();
  9. bool askToPlayAgain();
  10.  
  11. int main()
  12. {
  13. do
  14. {
  15. printIntro();
  16. playGame();
  17. } while (askToPlayAgain());
  18.  
  19.  
  20. system("pause");
  21. return 0;
  22. }
  23.  
  24. void playGame()
  25. {
  26. constexpr int enterTime = 5;
  27. for (int i = 0; i < enterTime; i++)
  28. {
  29. printGuessAnswer();
  30. printBar();
  31. }
  32. }
  33.  
  34. void printIntro()
  35. {
  36. // print the fucking introduction of the fucking game
  37. constexpr int word_length = 5;
  38.  
  39. cout << "Welcom to bullcow game\n";
  40. cout << "Can you guess the " << word_length;
  41. cout << " letter isogram that I am thinking about?\n";
  42. return;
  43. }
  44.  
  45. void printGuessAnswer()
  46. {
  47. // print the guess's answer not pass the answer to the variable
  48. string x;
  49.  
  50. cout << "enter your answer: ";
  51. do { getline(cin, x); } while(!x.size());
  52. cout << "your answer: " << x << endl;
  53. }
  54.  
  55. void printBar()
  56. {
  57. // print the fucking bar
  58. cout << "--------------------------------------\n";
  59. }
  60.  
  61. bool askToPlayAgain()
  62. {
  63. string str;
  64.  
  65. cout << "Do you want to play again?(Y/N): ";
  66. cin >> str;
  67.  
  68. return (str[0] == 'y' || str[0] == 'Y');
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement