-1

So I have made a menu and a guy helped me,
We have used enum in the menu is there anyother way i can do it, cause my teacher is not allowing me to use classes, files and arrays, please help, if u guys have anything simple and better i need it urgently..

here is the code:-

enum MenuState{MenuPlay,MenuHelp,MenuExit}; // the idea of using enum is that instead of using an int to represent a set of values, a type with a restricted set of values in used instead.
MenuState ms=MenuPlay;cout<<"                                                           *-=MOD=-* v1.0\n\n\n\n\n";
char ch=0;//or anything other than '\r'
while (ch!='\r')//IIRC getch returns '\r' when user hits enter
{
    system("CLS");

    switch (ms)
    {
        case MenuPlay:
            system("color 09");
            cout<<"                                                         *-=MOD=-* v1.0\n\n\n\n\n\n\n\n\n\n\n\n\n";
            cout<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<endl;
            cout<<b<<"                                                      --> PLAY                                                 "                                                                                                                                                                  <<b<<endl;
            cout<<b<<"                                                          HELP                                                 "                                                                                                                                                                                                       <<b<<endl;
            cout<<b<<"                                                          EXIT                                                 "                                                                                                                                                                                                       <<b<<endl;
            cout<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b;
            break;
        case MenuHelp:
            system("color 02");
            cout<<"                                                         *-=MOD=-* v1.0\n\n\n\n\n\n\n\n\n\n\n\n\n";
            cout<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<endl;
            cout<<b<<"                                                         PLAY                                                  "                                                                                                                                                                                                       <<b<<endl;
            cout<<b<<"                                                     --> HELP                                                  "                                                                                                                                                                  <<b<<endl;
            cout<<b<<"                                                         EXIT                                                  "                                                                                                                                                                                                       <<b<<endl;
            cout<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<endl;
            break;
        case MenuExit:
            system("color 0C");
            cout<<"                                                         *-=MOD=-* v1.0\n\n\n\n\n\n\n\n\n\n\n\n\n";
            cout<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<endl;
            cout<<b<<"                                                          PLAY                                                 "                                                                                                                                                                                                       <<b<<endl;
            cout<<b<<"                                                          HELP                                                 "                                                                                                                                                                                                       <<b<<endl;
           cout<<b<<"                                                      --> EXIT                                                 "                                                                                                                                                                  <<b<<endl;
            cout<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<b<<endl;
            break;
        default: //always provide default, some compilers will not compile until it is there
            cout<<"ERROR: Unknown state!\n";
    }
    ch=getch();//process more input
    switch (ch){
        case 'w':
        case 'W':
        ms=MenuPlay;
        break;
        case 'e':
        case 'E':
        ms=MenuHelp;
        break;
        case 'r':
        case 'R':
        ms=MenuExit;
        break;
        default:
             break;

    }

}
//now that we are out of the loop we know that the user hit enter. now we just check ms
switch (ms)
{
    case MenuPlay:

        break;
    case MenuHelp:
        //help was selected
        break;
    case MenuExit:
        //exit was selected
        break;

}

please anything simple i need it! urgently

2
Contributors
1
Reply
49
Views
2 Years
Discussion Span
Last Post by Stavros_1
1

what are you even trying to do? if its just a menu why so complicated?

just a while loop with an input, a switch. What is so hard about that? I'm not one to judge but I also have no idea what all those "b" are. instead make a function with a for loop like ->

void lotsOfBs()
{
    for(int i = 0; i < 555;i ++)
    {
        cout << b;
        if(i == 554)
            cout << endl;
    }
}

As for the menu I'm not going to do your homework and I hope nobody here either

Edited by Stavros_1: wrote look instead of loop

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.