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

Here’s output showing my win/loss messages…

I started working on this while waiting for a plane, and the whole frustrating experience of having flights delayed and sitting for hours in cramped seats inspired the story for my version of TripleX. Here is my code with the win/lost statements.

if (GuessSum == CodeSum && CodeProduct == GuessProduct)
    {
        std::cout <<"The airline officer congradulates you and lets you board the plane";
    }
    else
    {
        std::cout<< "The airline officer says that you didn't complete the puzzle correctly and now the filight is full, you now have to wait 3 hours for the next flight.";
    }

Ah, well… Would you look at that… :slight_smile:
triplex2

My TripleX with win and lose messages:

image

So for me it looks like this :slight_smile: :

if (GuessSum == CodeSum && GuessProduct==CodeProduct)
    {
        std::cout << "You have escaped!";
    }

    else
    {
        std::cout << "Wrong code, you have been captured again!";
    }```

image

Win Message:
image
Lose Message:
image

Here’s my code


/*  
    Remember to compile code, you need to type "cl [FILE_NAME].cpp"
    Remeber, this isn't case sensitive
*/


int main()
{
    // print the story to the terminal
    std::cout << "ATTEMPT 863 COMPLETE" << std::endl;
    std::cout << "STATUS: FAILURE" << std::endl;
    std::cout << "OBJECTIVE: BYPASS FIREWALL - INCOMPLETE" << std::endl;
    std::cout << "OBJECTIVE: CLEANSE HUMANITY - INCOMPLETE" << std::endl;

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

    const int CodeSum = CodeA + CodeB + CodeC;
    const int CodeProduct = CodeA * CodeB * CodeC;

    // print clues (CodeSum and CodeProduct) to the terminal
    std::cout << std::endl;
    std::cout << "DATA GATHERED:" << std::endl;
    std::cout << "  - CODE IS COMPRISED OF 3 NUMBERS [# # #]" << std::endl;
    std::cout << "  - NUMBERS ADD-UP TO: " << CodeSum << std::endl;
    std::cout << "  - NUMBERS MULTIPLY TO: " << CodeProduct << std::endl;
    std::cout << std::endl;
    std::cout << "INITIALIZING ATTEMPT 864" << std::endl;
    std::cout << std::endl;
    std::cout << "Username: nuclear3561" << std::endl;
    std::cout << "Password: *********************" << std::endl;
    std::cout << std::endl;
    std::cout << "Login Successful." << std::endl;
    std::cout << "For security, what is your 3-digit access code [# # #]:" << std::endl;

    // declaring the player's guess
    int GuessA, GuessB, GuessC;

    // obtains the players input and stores it into variables
    std::cin >> GuessA;
    std::cin >> GuessB;
    std::cin >> GuessC;

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

    // checks to see if player guess is correct
    if (GuessSum == CodeSum && GuessProduct == CodeProduct)
    {
        std::cout << std::endl;
        std::cout << "ATTEMPT 864 COMPLETE" << std::endl;
        std::cout << "STATUS: SUCCESSFUL" << std::endl;
        std::cout << "OBJECTIVE: BYPASS FIREWALL - COMPLETE" << std::endl;
        std::cout << "OBJECTIVE: CLEANSE HUMANITY - INCOMPLETE" << std::endl;
        std::cout << std::endl;
        std::cout << "# #  ###  #    #  " << std::endl;
        std::cout << "##    #   #    #  " << std::endl;
        std::cout << "#     #   #    #  " << std::endl;
        std::cout << "##    #   #    #  " << std::endl;
        std::cout << "# #  ###  ###  ###" << std::endl;
    }
    else
    {
        std::cout << std::endl;
        std::cout << "ATTEMPT 864 COMPLETE" << std::endl;
        std::cout << "STATUS: UNSUCCESSFUL" << std::endl;
        std::cout << "OBJECTIVE: BYPASS FIREWALL - INCOMPLETE" << std::endl;
        std::cout << "OBJECTIVE: CLEANSE HUMANITY - INCOMPLETE" << std::endl;
        std::cout << std::endl;
        std::cout << "D%TA GAT5E#ED:" << std::endl;
        std::cout << "  - COQE IS COMP^$%ED OF 3 NUT!@RS [# # #]" << std::endl;
        std::cout << "  - NUMB465^%4&*TO: " << std::endl;
        std::cout << "  - ^$^*&@&*(@#*^($: " << std::endl;
        std::cout << std::endl;
        std::cout << "INIT$^&*#^&*#@ ATT$^&*T 865" << std::endl;
        std::cout << "%^&%^*$%^&$^(*%(&%^(*$%$#*&&^)(^&^%&*$" << std::endl;
        std::cout << "^&^&(%^*$^*%^*&(%^*$^*(**^$" << std::endl;
        std::cout << "*(&*()^&%^$%$#&%&*(^(&)*^&*(^&*(rfyiuoghft&i%rt^tui%r^&*" << std::endl;
        std::cout << "&*)&*(^t&*(^&*%^*t&*th^*t*^&tr^vr^&t&*gftyf%&r&%^*r^f^t*^&(t*&yfgy*(f(" << std::endl;
        std::cout << "SYSTEM PURGED" << std::endl;
        
    }
    return 0;
}

You play as an AI who is trying to hack a nuclear facility and wipe out humanity.

For the Winning text and types in the correct guess, the console prints: “Kli-click! The code was correct and the safe is unlocked! Hurrah! Your travel plans are safe! You’ve certainly earned your vacation now!”;

If the player doesn’t guess correctly, the losing text that is printed reads: “Wait, why is something smouldering inside the safe… OH NOOOO!! You’ve failed and set off a trap that burned up your travel plans! GAME OVER”

Simple Spy Story

#include <iostream>

int main()
{
    // Set the Stage
    std::cout << "You are a secret agent breaking into a secure server room...";
    std::cout << std::endl;
    std::cout << "The computer display says: ENTER CODE" << std::endl;

    // Declaring the 3 Numbers
    const int CodeA = 4;
    const int CodeB = 6;
    const int CodeC = 2;

    // Print Sum & Product
    const int CodeSum = CodeA + CodeB + CodeC;
    const int CodeProduct = CodeA * CodeB * CodeC;

    std::cout << std::endl;
    std::cout <<"There are three numbers in the code. Your AI Buddy was able to give you two clues, but, will need your mind power to get the final code." << std::endl;
    std::cout << "First clue: The numbers add up to " << CodeSum << std:: endl;
    std::cout << "Second clue: The numbers multiply to get " << CodeProduct;
    
    int GuessA, GuessB, GuessC;


    std::cout << std::endl;
    std::cout << "Code:" << std::endl;
    std::cin >> GuessA;
    std::cin >> GuessB;
    std::cin >> GuessC;
    std::cout << std::endl;

    int GuessSum = GuessA + GuessB + GuessC;
    int GuessProduct = GuessA * GuessB * GuessC;
    
    if (GuessSum == CodeSum && GuessProduct == CodeProduct)
    {
         std::cout << "The computer Reads CORRECT";
    }
    else
    {
        std::cout << "The computer reads INCORRECT, the alarm goes off, and you are apprehended.";
    }
    return 0;
}

if the player succeeds the program prints congratulations the cops were left in the dust, if they loose the code prints you got busted game over , you now spend 20 years in jail.

TripleXWinLose

Microsoft (R) C/C++ Optimizing Compiler Version 19.21.27702.2 for x86
Copyright (C) Microsoft Corporation.  All rights reserved.

triplex.cpp
triplex.cpp(35): warning C4551: function call missing argument list
triplex.cpp(35): error C2568: 'identifier': unable to resolve function overload

When I tried to compile my project after adding my if/else win statement, it threw up this error. Here is my code:

 if (GuessAdd == SumAddition && GuessMultiply == SumMultiplication)
    {
      std::cout << " The computer slowly processes your code...";
      std::endl;
      std::cout << "You win! The computer quickly scans the database...but find nothing. Huh.";
    }
    else
    {
        std::cout << "The security system caught you! Try again? (Enter *triplex*.)"
    }

I’ve looked at the code for a few minutes now and can’t find any reason why it shouldn’t be working. The terminal says there are no issues, and I don’t understand the error code it’s throwing up. Whenever I type “triplex” into the terminal, it acts as if it hasn’t compiled/saved in a while (even though I know it has) and just does the simple you win message and not the one I have in the code. Not sure how I broke it, but I have…can anyone help me?

EDIT: I solved it…apparently you’re not allowed to use “std::cout << endl;” in a if/else statement?

My win lose come out as follows, and I never claimed to be a great artist lol


image

Just keeping it simple haha

Capture

    if(GuessSum == CodeSum && GuessProduct == CodeProduct)
    {
        std::cout << std::endl << "You win! The guests are delighted.";
    } 
    else 
    {
        std::cout << std::endl << "Whoops. That didn't go over so well...";
    }

screenshot

2019-08-12%20(4)

Privacy & Terms