Raised This Month: $51 Target: $400
 12% 

C++ Gaben test [Done]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Da_sk8rboy
Veteran Member
Join Date: Jul 2006
Old 02-14-2007 , 16:19   C++ Gaben test [Done]
Reply With Quote #1

Thank's for the help guys ;)
The .zip files are all up-to-date (The source code also) ;)

Thanks to
:
  • Xanimos
  • Zenith77
  • LittleDude
The .zip files contain:
  • The Gaben test Source.zip file. (Source code for program)
  • The Gaben test.exe (The program)
Thank's again for the help ;)

(I would appreciate it if someone could explain to me the loop Zenth77 was talking about. I'm fairly new to C++ so be nice.) ;)
Attached Files
File Type: zip Gaben test Source.zip (1.1 KB, 124 views)
File Type: zip Gaben test.zip (127.4 KB, 130 views)

Last edited by Da_sk8rboy; 02-18-2007 at 20:48.
Da_sk8rboy is offline
lunarwolfx
Member
Join Date: Feb 2005
Old 02-14-2007 , 16:36   Re: C++ help
Reply With Quote #2

well it's working correctly, it's just that the console shutdowns whenever the program ends.

I forgot what you have to add at the end of the function to make it ask you to press a key to continue, but I think it is getchar();
lunarwolfx is offline
Ephraim
New Member
Join Date: Feb 2007
Old 02-14-2007 , 16:36   Re: C++ help
Reply With Quote #3

if(killedByGaben)
cout << "\As you

\A ??

;)
Without this it works for me.

Ciao Ephraim
Ephraim is offline
Da_sk8rboy
Veteran Member
Join Date: Jul 2006
Old 02-14-2007 , 16:51   Re: C++ help
Reply With Quote #4

Ahh I forgot the "\n"
But now if you press 0 it exits.. Which its not suppose to do.. Its suppose to display:
Code:
 You take the shining Pickles, 
           but you have failed the second test!
           You've proven you're GREED. . .
           Game 0ver. . .
Also if you keep pressing 0 @ the very end if you comlete it its suppose to say:
Code:
                           Congratualations, you
                           have passed all three tests!
                           You exit the chamber & 
                           confront Gaben.
                           He tries to eat you whole 
                           but you move on.
                           With one swing of your trout it is over.
                           You and your computer live happily ever after.
                           The 3nd. . .
But it doesnt. anytime 0 is pressed the program is exited..
__________________
i stop around here and there.

Last edited by Da_sk8rboy; 02-14-2007 at 17:11.
Da_sk8rboy is offline
Zenith77
Veteran Member
Join Date: Aug 2005
Old 02-14-2007 , 20:57   Re: C++ help
Reply With Quote #5

You need to do a while loop, something like:

Code:
bool quit;
while (!quit)
{
    if (inpute == 0)
         quit = true;
}

system("PAUSE"); // This is optional :-).
Put the main program code in there :-). It's exiting like that because once it's done displaying everything (almost immediatly), it then has no more code to execute, thus ending the program.
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
Da_sk8rboy
Veteran Member
Join Date: Jul 2006
Old 02-14-2007 , 21:19   Re: C++ help
Reply With Quote #6

Yeah, Well i got most of it done (thanks Xanimos :p) But im still having trouble with one part. All the ones work besides the first test when you press 1 in the first test.... It exits the program.. But if you hit 0 then 1 it works on the second & third test.. Here my new code:

Code:
//*Britt Jamerson - Gaben, Take or go test! - v1.0*
#include <iostream>
using namespace std;   
int main( void )
{
    cout << "\n A code by Britt Jamerson aka Da_sk8rboy--no0bsawce!" 
            "\n+-----------------------------------------------------------------------+"
            "\n| Welcome to the Gaben take or go test!.                                |"
            "\n| Gaben has stolen your computer and it is up to you to get it back.    | "
            "\n| Gaben say's you must pass the Gaben take or go test! ! !              |"
            "\n+-----------------------------------------------------------------------+";
    bool clamsTaken, picklesTaken, killedByGaben;
    cout << "\n\nYou enter the first chamber."
            "\nIt's full of purple clam's, "
            "you cannot believe."
            "\nDo you take the clam's (1=Yes, 0=No)? ";
    cin >> clamsTaken;
    
    if(clamsTaken) 
    {
        cout << "\nYou keep the clams, but you have failed the first test."
                "\nGame 0ver. . .\n\n";
    }
    else 
    {
        cout << "Congratulations, "
                "you have passed the first test!"
                "\n\nYou enter the second chamber."
                " It is full of shining Pickles! ! !"
                "\nDo you take the shining pickles"
                "(1=Yes, 0=No)?";

        cin >> picklesTaken;

        if(picklesTaken) 
        {
            cout << "You take the Shining Pickles, "
                    "but you have failed the second test!"
                    "\nYou've proven you're GREED. . ."
                    "\nGame 0ver. . .\n\n";
        }
        else
        {
            cout << "Congratulations, you have passed the Second test!"
                    "\n\n You enter the Third chamber. "
                    "\n A no0b is being attacked by a MiniGaben!"
                    "\nDo you ignore the no0b & move on (1=Yes, 0=No)?";

            cin >> killedByGaben;
            if(killedByGaben)
            {
                cout << "\nAs you sneak by, the MiniGaben turn's his attenetion "
                        "to you."
                        "\nHe grabs you & eat's you whole with one bite. . ."
                        "You are now dead."
                        "\nGame 0ver. . .\n\n";
            }
            else
            {
                cout << "Congratualations, you"
                        " have passed all three tests!\n\n"
                        "You exit the chamber & "
                        "confront Gaben.\n\n"
                        "He tries to eat you whole "
                        "but you move on.\n"
                        "With one swing of your trout it is over.\n\n"
                        "You and your computer live happily ever after.\n\n"
                        "The End. . .\n\n";
            }
        }         
        system("PAUSE");
    }
    return 0;
}
If you want i can give you the update .exe To see what i mean?
__________________
i stop around here and there.
Da_sk8rboy is offline
LittleDude
Member
Join Date: Dec 2004
Location: Selah, WA
Old 02-14-2007 , 21:59   Re: C++ help
Reply With Quote #7

you gotta return 0 back to the calling program so it knows to end.

Code:
//*Britt Jamerson - Gaben, Take or go test! - v1.0*
#include <iostream>
using namespace std;   
int main( void )
{
    cout << "\n A code by Britt Jamerson aka Da_sk8rboy--no0bsawce!" 
            "\n+-----------------------------------------------------------------------+"
            "\n| Welcome to the Gaben take or go test!.                                |"
            "\n| Gaben has stolen your computer and it is up to you to get it back.    | "
            "\n| Gaben say's you must pass the Gaben take or go test! ! !              |"
            "\n+-----------------------------------------------------------------------+";
    bool clamsTaken, picklesTaken, killedByGaben;
    cout << "\n\nYou enter the first chamber."
            "\nIt's full of purple clam's, "
            "you cannot believe."
            "\nDo you take the clam's (1=Yes, 0=No)? ";
    cin >> clamsTaken;
    
    if(clamsTaken) 
    {
        cout << "\nYou keep the clams, but you have failed the first test."
                "\nGame 0ver. . .\n\n";

		return 0;
    }
    else 
    {
        cout << "Congratulations, "
                "you have passed the first test!"
                "\n\nYou enter the second chamber."
                " It is full of shining Pickles! ! !"
                "\nDo you take the shining pickles"
                "(1=Yes, 0=No)?";

        cin >> picklesTaken;

        if(picklesTaken) 
        {
            cout << "You take the Shining Pickles, "
                    "but you have failed the second test!"
                    "\nYou've proven you're GREED. . ."
                    "\nGame 0ver. . .\n\n";

			return 0;
        }
        else
        {
            cout << "Congratulations, you have passed the Second test!"
                    "\n\n You enter the Third chamber. "
                    "\n A no0b is being attacked by a MiniGaben!"
                    "\nDo you ignore the no0b & move on (1=Yes, 0=No)?";

            cin >> killedByGaben;
            if(killedByGaben)
            {
                cout << "\nAs you sneak by, the MiniGaben turn's his attenetion "
                        "to you."
                        "\nHe grabs you & eat's you whole with one bite. . ."
                        "You are now dead."
                        "\nGame 0ver. . .\n\n";

				return 0;
            }
            else
            {
                cout << "Congratualations, you"
                        " have passed all three tests!\n\n"
                        "You exit the chamber & "
                        "confront Gaben.\n\n"
                        "He tries to eat you whole "
                        "but you move on.\n"
                        "With one swing of your trout it is over.\n\n"
                        "You and your computer live happily ever after.\n\n"
                        "The End. . .\n\n";
            }
        }         
        system("PAUSE");
    }
    return 0;
}
__________________
It is stupid to be stupid, and stupid to not be stupid
LittleDude is offline
Send a message via AIM to LittleDude
Zenith77
Veteran Member
Join Date: Aug 2005
Old 02-14-2007 , 22:00   Re: C++ help
Reply With Quote #8

You probably have a logic error (I'm to lazy to look for it right now). But you still need to do the while loop thing.

Quote:
Originally Posted by LittleDude View Post
you gotta return 0 back to the calling program so it knows to end.
That's his problem, he doesn't want it to end. And no, you don't have to return 0 or return anything for that matter (hence return type void), as most compilers know how to handle this.
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
Da_sk8rboy
Veteran Member
Join Date: Jul 2006
Old 02-14-2007 , 22:01   Re: C++ help
Reply With Quote #9

talking to dude.
That doesnt solve the problem i have. Still choosing ''1'' in the first test exits program..
__________________
i stop around here and there.
Da_sk8rboy is offline
Da_sk8rboy
Veteran Member
Join Date: Jul 2006
Old 02-14-2007 , 22:03   Re: C++ help
Reply With Quote #10

Quote:
Originally Posted by Zenith77 View Post
You probably have a logic error (I'm to lazy to look for it right now). But you still need to do the while loop thing.



That's his problem, he doesn't want it to end. And no, you don't have to return 0 or return anything for that matter (hence return type void), as most compilers know how to handle this.
could you explain exactly what the loop is doing.. (im fairly new to C++) havent got to loops yet..
__________________
i stop around here and there.
Da_sk8rboy is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 11:16.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode