# Section 2: TripleX Progress

I took hours but, I have finally completed my first game code! This is gonna be a long journey but, itβs so gonna be worth it! (I hope I formatted it correctly)

``````#include <iostream>
#include <ctime>
/*
You are a cyborg chef living in a world where humans and robots co-exist. You own a restaurant that is meant for robot-based dishes
You're trying to create the ultimate mix of binary flavor codes for all robots to taste.
*/

void PrintIntroduction(int Difficulty)
{
// Print welcome messages to the terminal
std::cout << "You are a cyborg chef trying to create recipe #" << Difficulty;
std::cout << " for your robot restaurant...\nChoose the right numbers in order to get the correct binary ingredients for flavor...\n\n";

}

bool PlayGame(int Difficulty)
{

PrintIntroduction(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 to the terminal
std::cout << "There are 3 numbers in the code";
std::cout << "\nThe flavors add-up to: " << CodeSum;
std::cout << "\nThe flavors 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;

//If the players' guess is correct
if (GuessSum == CodeSum && GuessProduct == CodeProduct)
{
std::cout << "\nYou're recipe was a succces you can taste all the flavors of binary!\n\n";
return true;
}

else
{
std::cout << "\nThe recipe was a flop and mistakes were made! Try Again!\n\n";
return false;
}
}

int main()
{
srand(time(NULL));
int LevelDifficulty = 1;
int const MaxDifficulty = 5;
while (LevelDifficulty <= MaxDifficulty) // Loop the game until all levels completed
{
bool bLevelComplete = PlayGame(LevelDifficulty);

if (bLevelComplete)
{
++LevelDifficulty;
}
else
{
std::cin.clear(); //Clears any errors