Raised This Month: $ Target: $400
 0% 

C++ help..


Post New Thread Reply   
 
Thread Tools Display Modes
stupok
Veteran Member
Join Date: Feb 2006
Old 04-22-2007 , 18:09   Re: C++ help..
Reply With Quote #11

You have the answer to your question in your code.
stupok is offline
LittleDude
Member
Join Date: Dec 2004
Location: Selah, WA
Old 04-22-2007 , 18:15   Re: C++ help..
Reply With Quote #12

This isn't the best way to do it, but with my limited knowledge of C++, this should work fine for what you're doing... just call back to main and it'll ask the user for input again.

PHP Code:
#include <iostream>

using namespace std;

void ShowFirstOption();
void ShowSecondOption();
void ShowThirdOption();
void ShowFourthOption();

int main()
{

    
int choice;

    
cout << "\t\n\n+-----------------------------------------------------------------------+"
            "\n|                                                                       |"
            "\n|        C++ Code / Program written Brit no0bsawcE! Jamerson!           |"
            "\t|        Software under-developement! :)                                | "
            "\n|        visit us at www.mo0seclan.xanimos.com                          |"
            "\t|                                                                       |"
            "\n+-----------------------------------------------------------------------+\n"
            "\n\n\t Select a choice that you would like to learn more information about:\n\n"
            "1: CS4$!\n" 
            "2: <Mo0se> Clan Community!\n" 
            "3: Credits!\n"
            "4: Program info!\n"
            "0: Exit!\n\n"
;

    
cin >> choice;

    
/*if( choice < 0 || choice > 3 ) // dont really need to check this because the default case will handle it
    {
        exit(0);
    }
    else
    {*/

    
switch(choice)
    {
        case 
1ShowFirstOption();
        break;
        
        case 
2ShowSecondOption();
        break;
        
        case 
3ShowThirdOption();
        break;

        case 
4ShowFourthOption();
        break;
        
        default: exit(
1);
        break;
    }
    return 
0;
    }


void ShowFirstOption()
{
    
cout << "YOU'VE SELECTED OPTION #1\n\n"
            "\t[---------------------------CS4$--------------------------------]\n"
            "\t  Counter-Strike4Cash is an online arena for cash and prizes.\n"
            "\t  Everyone will risk the same amount of\n" 
            "\t  cash PR(Per Round.)\n"
            "\t  When you take a portion of someones HP, you recieve an equal portion\n" 
            "\t  of cash from them.\n"
            "\t  You Can Check them out at www.counter-strike4cash.com!\n"
            "\t[---------------------------CS4$--------------------------------]\n\n\t\t"
;

            
main();
        
            
system("PAUSE");
}

void ShowSecondOption()
{
    
cout << "YOU'VE SELECTED OPTION #2\n\n"
            "\t[---------------------------Mo0se--------------------------------]\n"
            "\t  <Mo0se> Clan was founded by myself an THEpro.\n"
            "\t  We are currently Recruiting only expierenced CSS Surf Players."
            "\t          Check out our site @ www.mo0seclan.xanimos.com !\n"
            "\t[---------------------------Mo0se--------------------------------]\n\n\n"
            "[---------------------------Members--------------------------------]\n\n"
            "  1. no0bsawcE! <Mo0se> - Brit Jamerson."
            "\n  2. THEpro <Mo0se> - Brad Duke."
            "\n  3. Chinese <Mo0se> - Dustin Lum.\n"
            "\b  4. TiM <Mo0se> - Tim.\n"
            "[---------------------------Members--------------------------------]\n\n\t"
;

            
main();

            
system("PAUSE");
}

void ShowThirdOption()
{
    
cout << "YOU'VE SELECTED OPTION #3\n\n"
            "\t[---------------------------Credits--------------------------------]\t"
            "\t  1. no0bsawcE! <Mo0se> - Brit Jamerson(Me)\n"
            "\t  2. LittleDude @ Amxmodx forums for some assistance with code.\n"
            "\t[---------------------------Credits--------------------------------]\n\n\n\t\t\t"
;

            
main();

            
system("PAUSE");


void ShowFourthOption() 
{
     
cout << "YOU'VE SELECTED OPTION #4\n\n"
             "\t[---------------------------Program Info-----------------------------]\n"
             "\t  Version        = 1.0b.\n"
             "\t  Current State  = Beta.\n"
             "\t  Update1(1.0a)  = Removed all if elsestatements.\n"
             "\t  Update2(1.0b)  = Rebuilt the back-bone of the code.\n"
             "\t  Lead Developer = Brit no0bsawcE! Jamerson\n"
             "\t[---------------------------Program Info-----------------------------]\n\n\n\t\t"
;

            
main();

            
system("PAUSE");

__________________
It is stupid to be stupid, and stupid to not be stupid
LittleDude is offline
Send a message via AIM to LittleDude
Da_sk8rboy
Veteran Member
Join Date: Jul 2006
Old 04-22-2007 , 18:23   Re: C++ help..
Reply With Quote #13

Quote:
Originally Posted by stupok69 View Post
You have the answer to your question in your code.
What is it?
__________________
i stop around here and there.
Da_sk8rboy is offline
LittleDude
Member
Join Date: Dec 2004
Location: Selah, WA
Old 04-22-2007 , 18:24   Re: C++ help..
Reply With Quote #14

This one should actually work pretty good too, I just made a new function that displays the menu information again and waits for user input, once it displays the information it shows the menu again and lets the user decide which option they want to choose until they hit exit.

PHP Code:
#include <iostream>

using namespace std;

void ShowFirstOption();
void ShowSecondOption();
void ShowThirdOption();
void ShowFourthOption();
void ShowInfo();

int main()
{

    
int choice 0;

    
cout << "\t\n\n+-----------------------------------------------------------------------+"
            "\n|                                                                       |"
            "\n|        C++ Code / Program written Brit no0bsawcE! Jamerson!           |"
            "\t|        Software under-developement! :)                                | "
            "\n|        visit us at www.mo0seclan.xanimos.com                          |"
            "\t|                                                                       |"
            "\n+-----------------------------------------------------------------------+\n"
            "\n\n\t Select a choice that you would like to learn more information about:\n\n"
            "1: CS4$!\n" 
            "2: <Mo0se> Clan Community!\n" 
            "3: Credits!\n"
            "4: Program info!\n"
            "0: Exit!\n\n"
;

    
cin >> choice;

    
/*if( choice < 0 || choice > 3 ) // dont really need to check this because the default case will handle it
    {
        exit(0);
    }
    else
    {*/

    
switch(choice)
    {
        case 
1ShowFirstOption();
        break;
        
        case 
2ShowSecondOption();
        break;
        
        case 
3ShowThirdOption();
        break;

        case 
4ShowFourthOption();
        break;
        
        default: exit(
0);
        break;
    }
    return 
0;
    }


void ShowFirstOption()
{
    
cout << "YOU'VE SELECTED OPTION #1\n\n"
            "\t[---------------------------CS4$--------------------------------]\n"
            "\t  Counter-Strike4Cash is an online arena for cash and prizes.\n"
            "\t  Everyone will risk the same amount of\n" 
            "\t  cash PR(Per Round.)\n"
            "\t  When you take a portion of someones HP, you recieve an equal portion\n" 
            "\t  of cash from them.\n"
            "\t  You Can Check them out at www.counter-strike4cash.com!\n"
            "\t[---------------------------CS4$--------------------------------]\n\n\t\t"
;

            
ShowInfo();
        
            
system("PAUSE");
}

void ShowSecondOption()
{
    
cout << "YOU'VE SELECTED OPTION #2\n\n"
            "\t[---------------------------Mo0se--------------------------------]\n"
            "\t  <Mo0se> Clan was founded by myself an THEpro.\n"
            "\t  We are currently Recruiting only expierenced CSS Surf Players."
            "\t          Check out our site @ www.mo0seclan.xanimos.com !\n"
            "\t[---------------------------Mo0se--------------------------------]\n\n\n"
            "[---------------------------Members--------------------------------]\n\n"
            "  1. no0bsawcE! <Mo0se> - Brit Jamerson."
            "\n  2. THEpro <Mo0se> - Brad Duke."
            "\n  3. Chinese <Mo0se> - Dustin Lum.\n"
            "\b  4. TiM <Mo0se> - Tim.\n"
            "[---------------------------Members--------------------------------]\n\n\t"
;

            
ShowInfo();

            
system("PAUSE");
}

void ShowThirdOption()
{
    
cout << "YOU'VE SELECTED OPTION #3\n\n"
            "\t[---------------------------Credits--------------------------------]\t"
            "\t  1. no0bsawcE! <Mo0se> - Brit Jamerson(Me)\n"
            "\t  2. LittleDude @ Amxmodx forums for some assistance with code.\n"
            "\t[---------------------------Credits--------------------------------]\n\n\n\t\t\t"
;

            
ShowInfo();

            
system("PAUSE");


void ShowFourthOption() 
{
     
cout << "YOU'VE SELECTED OPTION #4\n\n"
             "\t[---------------------------Program Info-----------------------------]\n"
             "\t  Version        = 1.0b.\n"
             "\t  Current State  = Beta.\n"
             "\t  Update1(1.0a)  = Removed all if elsestatements.\n"
             "\t  Update2(1.0b)  = Rebuilt the back-bone of the code.\n"
             "\t  Lead Developer = Brit no0bsawcE! Jamerson\n"
             "\t[---------------------------Program Info-----------------------------]\n\n\n\t\t"
;

            
ShowInfo();

            
system("PAUSE");
}

void ShowInfo()
{
            
cout << "\n\n\t Select a choice that you would like to learn more information about:\n\n"
            "1: CS4$!\n" 
            "2: <Mo0se> Clan Community!\n" 
            "3: Credits!\n"
            "4: Program info!\n"
            "0: Exit!\n\n"
;

            
int choice 0;

            
cin >> choice;

    switch(
choice)
    {
        case 
1ShowFirstOption();
        break;
        
        case 
2ShowSecondOption();
        break;
        
        case 
3ShowThirdOption();
        break;

        case 
4ShowFourthOption();
        break;
        
        default: exit(
0);
        break;
    }

        
system("PAUSE");

__________________
It is stupid to be stupid, and stupid to not be stupid

Last edited by LittleDude; 04-22-2007 at 18:39. Reason: forgot to put the code..
LittleDude is offline
Send a message via AIM to LittleDude
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 06:35.


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