#include
#include
void PlayIntroduction(int Difficulty)
{
//print Welcome Message
std::cout << "\n\nYou are a secret agent breaking into a Level" << Difficulty;
std::cout << " secure server room...\nEnter the correct code to continue...\n\n";
}
bool PlayGame(int Difficulty)
{
PlayIntroduction(Difficulty);
// Declare 3 Number Code
const int CodeA = rand() % Difficulty + Difficulty;
const int CodeB = rand() % Difficulty + Difficulty;
const int CodeC = rand() % Difficulty + Difficulty;
const int CodeSum = CodeA + CodeB + CodeC;
const int CodeProduct = CodeA * CodeB * CodeC;
//Print sum and product on to the terminal
std::cout << "+There are 3 numbers in the code";
std::cout << "\n+The code add-up to give:-" << CodeSum;
std::cout << "\n+The codes multiply to give:-" << CodeProduct << std::endl;
//Store Player Guess
int GuessA, GuessB, GuessC;
std::cin >> GuessA >> GuessB >> GuessC;
int GuessSum = GuessA + GuessB + GuessC;
int GuessProduct = GuessA * GuessB * GuessC;
//Check if the player guess is correct or not
if (GuessSum == CodeSum && GuessProduct == CodeProduct)
{
std::cout << "\n***Weldone Agent...You're doing great...You just received a code file***";
return true;
}
else
{
std::cout << "\n***PLease retry...Other wise you would be caugth***";
return false;
}
}
int main()
{
srand(time(NULL));
int LevelDifficulty = 1;
int const MaxDifficulty = 5;
while (LevelDifficulty <= MaxDifficulty)
{
bool bLEVELCOMPLETE = PlayGame(LevelDifficulty);
std::cin.clear(); // Clears any errors
std::cin.ignore(); // Discards the buffer
if (bLEVELCOMPLETE)
{
++LevelDifficulty;
}
}
std::cout << "\n***Congo...You received all the code file you just needed***";
return 0;
}