i m trying to build a turn based text game but im kinda of confused on the menu's
ok here is my issue i want to have 4 menu's in my game

menuDisplay
selectMenu
fightMenu
shopMenu


now what i want is the menuDisplay to be the welecome menu where the user make
begins. the "the selectMenu " will display the fight ,save,shop and quit.
ok her is my dilema is im tryin to figure out is how can i move from the switch to the next menu and continue into the next menu once a player has entered his name

the two issues are what to i need to establish if .else or another switch maybe a do while? im not sure
also ,
how can i code a ck to return if the user has selected his name properly
example: user enters 'eric' i want it to say "eric is this correct" ? y- for yes n-no an be able to return if entered incorrectly

#include <iostream>
#include <string>
#include <fstream>

using namespace std;

int main()
{
  ifstream loadFile;
  string playerName;
  char menuDisplay;
  char selectMenu;
  char letter;
	
   //menuDisplay

   cout << "Welcome to Space Gladiator Coliseum"
		 << endl;

   while (menuDisplay);
   {
//display menu 
     
      cout << "What would you like to do?" << endl;
      cout << "(enter the letter of your choice)" << endl;
      cout << "Press 'N' - To Begin a New Game"  << endl;
      cout << "Press 'L' - To Load a Previous Game " << endl;
      cout << "Press 'Q' - To Quit" << endl;
		
//choice
      cin >> letter;

    switch (letter)
     {
       case'n':
       case'N':
       cout << " Please Enter Your Fighters Name: " << endl;
       
       cin >> playerName;
			

       if ( playerName < 10 );
        {
          return playerName;
          cout << playerName << " Let's Begin " << endl; 
	}
	else 
         {
	cout << " You have exceed 10 characters for a name." << endl;
	cout << " Please Re-enter Name " << endl;

//problem------>
//how to return user name to see if correct
//how to move to next menu 
	}

	return 0;
	  }
    }

}

As far as the problem with re-entering the name if they messed up, just put a do/while loop around where they enter the name, like below.

char ans="n";
       do     
       {  
       cout << " Please Enter Your Fighters Name: " << endl;
       
       cin >> playerName;

       cout << "You have entered " << playerName << ". Is this correct? (y/n)" << endl;
			

       if ( playerName < 10 );
         {
          return playerName;
          cout << playerName << " Let's Begin " << endl; 
         }
	else 
         {
	cout << " You have exceed 10 characters for a name." << endl;
	cout << " Please Re-enter Name " << endl;
         }
         }
         while((ans !='Y')&&(ans !='y'));

It's been about a year since I worked with C++ so the syntax might not be exact, but the logic is still there. I'm not 100% sure what your question is with the menus, but couldn't you just make them functions and call them in the order you want them to display?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.