Advertisement
Guest User

Untitled

a guest
May 26th, 2019
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.22 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. void PrintIntroduction (int Difficulty)
  4. {
  5.     // Printing welcome messages to the terminal
  6.     std::cout << "\n\nYou are a blackwatch operative breaching a secure overwatch facility.\nTo continue, you need to enter enter the correct code on the keypad...\n";
  7.     std::cout << "You are on level " << Difficulty << ".\n\n";
  8.     std::cout << "   |  _ \\| |          | |                 | |     | |  \n";
  9.     std::cout << "   | |_) | | __ _  ___| | ____      ____ _| |_ ___| |__  \n";
  10.     std::cout << "   |  _ <| |/ _` |/ __| |/ /\\ \\ /\\ / / _` | __/ __| '_ \\ \n";
  11.     std::cout << "   | |_) | | (_| | (__|   <  \\ V  V / (_| | || (__| | | | \n";
  12.     std::cout << "   |____/|_|\\__,_|\\___|_|\\_\\  \\_/\\_/ \\__,_|\\__\\___|_| |_| \n\n";
  13. }
  14.  
  15. bool PlayGame ()
  16. {
  17.     PrintIntroduction(7);
  18.  
  19.     // Declaring the 3 numbers for the code
  20.     const int CodeA = 4;
  21.     const int CodeB = 2;
  22.     const int CodeC = 3;
  23.  
  24.     const int CodeSum = CodeA + CodeB + CodeC;
  25.     const int CodeProduct = CodeA * CodeB * CodeC;
  26.  
  27.     // Print the riddle
  28.     std::cout << " + There are 3 numbers in the code.\n";
  29.     std::cout << " + The codes add-up to " << CodeSum << ".\n";
  30.     std::cout << " + The codes multiply to give " << CodeProduct << ".\n\n";
  31.     int GuessA, GuessB, GuessC;
  32.  
  33.     // Asking for three guess numbers
  34.     std::cout << "Enter your code: "; std::cin >> GuessA >> GuessB >> GuessC;
  35.     std::cout << "You entered: " << GuessA << " " << GuessB << " " << GuessC << std::endl << std::endl;
  36.    
  37.     int GuessSum = GuessA + GuessB + GuessC;
  38.     int GuessProduct = GuessA * GuessB * GuessC;
  39.  
  40.     // Check if player guess is correct
  41.     if (GuessSum == CodeSum && GuessProduct == CodeProduct)
  42.     {
  43.         std::cout << "You win!";
  44.         return true;
  45.     }
  46.     else
  47.     {
  48.         std::cout << "You lose!";
  49.         return false;
  50.     }
  51. }
  52.  
  53. int main()
  54. {
  55.     int LevelDifficulty = 1;
  56.     while (true)
  57.     {
  58.         bool bLevelComplete = PlayGame();
  59.         std::cin.clear();   // Clears any errors
  60.         std::cin.ignore();  // Discards the buffer
  61.  
  62.         if (bLevelComplete)
  63.         {
  64.             ++LevelDifficulty;  // Increases the level difficulty by 1
  65.         }
  66.        
  67.     }
  68.     return 0;
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement