Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- void PrintIntroduction (int Difficulty)
- {
- // Printing welcome messages to the terminal
- 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";
- std::cout << "You are on level " << Difficulty << ".\n\n";
- std::cout << " | _ \\| | | | | | | | \n";
- std::cout << " | |_) | | __ _ ___| | ____ ____ _| |_ ___| |__ \n";
- std::cout << " | _ <| |/ _` |/ __| |/ /\\ \\ /\\ / / _` | __/ __| '_ \\ \n";
- std::cout << " | |_) | | (_| | (__| < \\ V V / (_| | || (__| | | | \n";
- std::cout << " |____/|_|\\__,_|\\___|_|\\_\\ \\_/\\_/ \\__,_|\\__\\___|_| |_| \n\n";
- }
- bool PlayGame ()
- {
- PrintIntroduction(7);
- // Declaring the 3 numbers for the code
- const int CodeA = 4;
- const int CodeB = 2;
- const int CodeC = 3;
- const int CodeSum = CodeA + CodeB + CodeC;
- const int CodeProduct = CodeA * CodeB * CodeC;
- // Print the riddle
- std::cout << " + There are 3 numbers in the code.\n";
- std::cout << " + The codes add-up to " << CodeSum << ".\n";
- std::cout << " + The codes multiply to give " << CodeProduct << ".\n\n";
- int GuessA, GuessB, GuessC;
- // Asking for three guess numbers
- std::cout << "Enter your code: "; std::cin >> GuessA >> GuessB >> GuessC;
- std::cout << "You entered: " << GuessA << " " << GuessB << " " << GuessC << std::endl << std::endl;
- int GuessSum = GuessA + GuessB + GuessC;
- int GuessProduct = GuessA * GuessB * GuessC;
- // Check if player guess is correct
- if (GuessSum == CodeSum && GuessProduct == CodeProduct)
- {
- std::cout << "You win!";
- return true;
- }
- else
- {
- std::cout << "You lose!";
- return false;
- }
- }
- int main()
- {
- int LevelDifficulty = 1;
- while (true)
- {
- bool bLevelComplete = PlayGame();
- std::cin.clear(); // Clears any errors
- std::cin.ignore(); // Discards the buffer
- if (bLevelComplete)
- {
- ++LevelDifficulty; // Increases the level difficulty by 1
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement