#include <iostream>
#include <ctime>
void PrintIntroduction(int Diffculty)
{
//Coment
std::cout << "\n\nYou are a secret agent breaking into a "<< Diffculty;
std::cout << " secure server room...\nEnter the correct code to continue...\n\n";
}
bool PlayGame(int Diffculty)
{
PrintIntroduction(Diffculty);
const int CodeA = rand() % Diffculty;
const int CodeB = rand() % Diffculty;
const int CodeC = rand() % Diffculty;
const int CodeSum = CodeA + CodeB + CodeC;
const int CodeProduct = CodeA * CodeB * CodeC;
/*
Comment
*/
std::cout << std::endl;
std::cout << "There are 3 nember in the code";
std::cout << "\nThe codes add-up to: " << CodeSum ;
std::cout << "\nThe codes multiply to give: " << CodeProduct << std::endl;
//Store Player guess
int GuessA,GuessB,GuessC;
std::cin >> GuessA >> GuessB >> GuessC;
//std::cout << "You Entered: " << GuessA << GuessB << GuessC;
int GuessSum = GuessA + GuessB + GuessC;
int GuessProduct = GuessA * GuessB * GuessC;
//std::cout << "The codes add-up to: " << GuessSum << std::endl;
//std::cout << "The codes multiply to give: " << GuessProduct << std::endl;
//Check the player Guess
if(GuessSum==CodeSum && GuessProduct== CodeProduct)
{
std::cout << "You Win \n";
return true;
}
else
{
std::cout << "You Lose \n";
return false;
}
}
int main()
{
srand(time(NULL));
int LevelDifficalty = 1;
int const MaxDiffculty=5;
while (LevelDifficalty <= MaxDiffculty)//loop game
{
std::cout << rand() % 10 << "\n";
bool bLevelComplete = PlayGame(LevelDifficalty);
std::cin.clear();//Clear any Error
std::cin.ignore();//Discard the buffer
if (bLevelComplete)
{
++LevelDifficalty;
}
}
std::cout << "You is God!! ";
return 0;
}
コメント