Question on Switch Statements!

Hello,


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
switch ( choice )
{
  case 4: cout<< "You look around, and look around at the silent, dreary, mysterious enviorment of the run-down abandoned airbase. As you look, you see a  fast flicker of movement jet pass "<<endl;
  cout<< "your vision. Your muscles tense up as you firm your hand on the handle of your gun."<<endl;
  break;
  case 5: cout<< " You slowly go up the worn-down stairs eyes flitting back and forth for any sign of movement"<<endl;
  break;
  case 6:cout<< "You decide to camp out and wait for your enemy..."<<endl;
  cout<< "..."<<endl;
  cout<< "..."<<endl;
  cout<< " Suddenly, you hear the slow but steady thump of footsteaps homing in on your position... The zombies begin to breach the wall "<<endl;
  cout<< "and the begin to pile in on your position."<<endl;
  break;
  case 7: cout<<" Since, there are no zombies in your area, you fire your gun, it's bullets bouncing harmlessly across the area."<<endl;
  break;
  case 8: cout<<" Since, there are no balconies, or rooftops in this location the Snipe Incoming Zombie Option will not be available to use."<<endl;
  break;
  case 9: cout<<"You board up the windows with a wooden plank, and some nails, in an effort to slow the zombies down."<<endl;
  break;
  case 10: cout<<"You decide to terminate your current game session!"<<endl;
  break;
}


Here is my question:

How do you make a switch statement lead into another switch statement within a case?

Please let me know if this makes any sense at all. Thanks.
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
switch ( foo )
{
    case bar:
        switch( baz )
        {
            case foobaz:
                switch( foobar )
                {
                    ...
                }
                break;
        }
        break;
}


Please let me know if this makes any sense at all.

It makes sense programatically but it might be hard to make sense of the resulting code. You'll probably do well to encapsulate a menu along with its choices and outcomes.
Thanks so much, shacktar!

I'll do my best.
Topic archived. No new replies allowed.