 # What do you print when the player wins/loses Triple X?

G:\TripleX>triplex
You’re a CIA agent breaking into a KGB super computer.
You need to find the password for each terminal to continue…

• The password consists of 3 numbers.
• The 3 numbers add up to: 15
• The 3 numbers multiply to make: 120

6 5 4

You entered: 654
You win!
G:\TripleX>triplex
You’re a CIA agent breaking into a KGB super computer.
You need to find the password for each terminal to continue…

• The password consists of 3 numbers.
• The 3 numbers add up to: 15
• The 3 numbers multiply to make: 120

8 8 8

You entered: 888
You lose!
G:\TripleX>

This has been a fun challenge so far and got my brain working, feels much more applicable already than attempts I have made to learn in the past.

For my game, I went with nuclear hazard, these are my messages for win/lose:

``````if (GuessSum == CodeSum && GuessProduct == CodeProduct)
{
std::cout << "Access granted, you managed to cancel the launch. Congratulations!, humanity gets to see another day." << std::endl;
}
else
{
std::cout << "Access denied, the missiles were launched, WW3 started, humanity is doomed" << std::endl;
}``````
``````#include <iostream>
//to read player input and progress levels in difficulty or end game
int main()
{
//game start
std:: cout<< "You are a TSA agent at Newark Airport, a bag has been detected to have a bomb inside it!"<<std::endl;
std:: cout<< "You must solve the riddles on the lock, to open the bag and diffuse the bomb. Hurry!"<<std::endl;
std::cout<< std::endl;
//code numbers
const int CodeA = 3;
const int CodeB = 4;
const int CodeC = 5;
const int CodeSum = CodeA+CodeB+CodeC;
const int CodeProduct = CodeA*CodeB*CodeC;
//hints
std::cout<<"+There are three numbers in the code: "<<std::endl;
std::cout<<"+The sum of the numbers is: "<<CodeSum<<std::endl;
std::cout<<"+The product of the numbers is: "<<CodeProduct<<std::endl;
std::cout<< std::endl;
//player guess variable
int GuessA,GuessB,GuessC;
std::cin>>GuessA>>GuessB>>GuessC;
//guess sums and products
int GuessSum,GuessProduct;
GuessSum = GuessA+GuessB+GuessC;
GuessProduct = GuessA*GuessB*GuessC;
//check condition
if(GuessSum==CodeSum && GuessProduct == CodeProduct)
{
std::cout<<"The bomb has been defused. Phew!"<<std::endl;
}
else
{
std::cout<<"BOOM!"<<std::endl;
}
return 0;
}
``````

I am drawing inspiration from Indiana Jones/Uncharted/Tomb Raider series.

If the user enters the code correctly then: BUT! If the numbers are wrong then…

Here’s the code if someone wants to replicate the game

``````#include <iostream>

// Main function
int main()
{
// Introduction of the game story
std::cout << std::endl;
std::cout << "You are an explorer, attempting to retrieve a treasure from the tomb of the last maharaja." << std::endl;
std::cout << "The walls have 3 empty spaces and there are numbered tiles in the ground. The walls say:" << std::endl;
std::cout << "You need to enter the correct numbers to enter the next room ..." << std::endl;
std::cout << std::endl;

// Declare 3 number code
const int CodeA = 4;
const int CodeB = 3;
const int CodeC = 2;

// Compute and declare sum and products
const int CodeSum = CodeA + CodeB + CodeC;
const int CodeProduct = CodeA * CodeB * CodeC;

// Show messages with hints about the numbers
std::cout << "The sum of the three numbers is " << CodeSum << "." << std::endl;
std::cout << "The product of the three numbers is " << CodeProduct << "." << std::endl;
std::cout << std::endl;

// Initialize player's guesses
int GuessA, GuessB, GuessC;

// User input
std::cout << "Insert the tiles: ";
std::cin >> GuessA;
std::cin >> GuessB;
std::cin >> GuessC;
std::cout << std::endl;

// Feedback to user
std::cout << "In the walls there are three tiles: " << GuessA << " " << GuessB << " " << GuessC << std::endl << std::endl;

// GuessSum and GuessProduct
int GuessSum = GuessA + GuessB + GuessC;
int GuessProduct = GuessA * GuessB * GuessC;

// Check if answer is correct
if (GuessSum == CodeSum && GuessProduct == CodeProduct) {
std::cout << "The room starts to rumble and a secret door opens on the wall. You survived this trial!" << std::endl;
}

else {
std::cout << "The room starts to rumble and the floor collapses as you tried to run to the exit. The maharaja has claimed yet another victim of greed..." << std::endl;
}

// Close
std::cout << std::endl;
return 0;
}
``````