#include
#include
void PlayIntroduction(int Difficulty)
{
std::cout << "if You want to free you friends, play the codez to save them...you are in level "<< Difficulty;
std::cout << "\nif codez is correct then one will be released\n";
std::cout << std::endl;
}
bool PlayGame(int Difficulty)
{
PlayIntroduction(Difficulty);
//std value needs to find by player
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 CodeProd=CodeA * CodeB * CodeC;
std::cout << "--> There are three numberes in the codez\n";
std::cout << "--> The addition of all codez " << CodeSum << std::endl;
std::cout << "--> The product of all codez " << CodeProd << std::endl;
//guess of playes
int GuessA;
int GuessB;
int GuessC;
std::cin >> GuessA >>GuessB >>GuessC;
std::cout << std::endl;
const int GuessSum=GuessA + GuessB + GuessC;
const int GuessProd=GuessA * GuessB * GuessC;
//checking if player got the correct guess
if(CodeSum==GuessSum && CodeProd==GuessProd)
{
std::cout << "you saved your friends\nMove on to next level to save the next friend\n\n";
return true;
}
else
{
std::cout<< "you murdered your friends\nGiving you a chance to save your friend\n\n";
return false;
}
}
int main()
{
srand(time(NULL));//creat new random sequence based on time of day
int LevelDifficulty=1;
const int TotalLevel=3;
while (TotalLevel >= LevelDifficulty)
{
bool LevelCompleted=PlayGame(LevelDifficulty);
std::cin.clear();//clear any errors
std::cin.ignore();//discard any buffers
if(LevelCompleted)
{
++LevelDifficulty;
}
}
std::cout<< “Congratulation !!!.. you have saved all your friends \n”;
return 0;
}