Hi! I was hoping if it were possible to go into a void from a do switch menu. I have already got the exiting game option to work, but I need some help on the other 3 options. Any help would be appreciated!
int main()
{
int MenuRepeat;
int UserSelection;
int a, b, c;
MenuRepeat = TRUE;
do
{
cout << endl;
cout << "Welcome! Please pick one of the following options. \n1. Play BlackJack \n2. Play Hangman \n3. Play Snake \n4. Quit \nOption: ";
cin >> UserSelection;
cout << endl;
switch (UserSelection)
{
case 1: &blackjack::BlackJack;
break;
case 2: &hangman::Hangman;
break;
case 3: &snake::Snake;
break;
case 4: MenuRepeat = FALSE();
break;
default: cout << "Incorrect Option. Please either play one of the games or Quit." << endl;
break;
}
} while (UserSelection != 4);
return 0;
}
void blackjack::BlackJack()
{
cout << "Welcome to BlackJack!";
}
void hangman::Hangman()
{
cout << "Welcome to Hangman!";
}
void snake::Snake()
{
cout << "Welcome to Snake!";
}
Right, the options now fall into the voids and read out the comments. The header files are the same.
This is just a basic menu to begin with. Hopefully, in time, I can expand on it. Also, I know I'm not very good at coding, but that's what websites like these are for, to learn from your mistakes. Thanks for the help you gave me!
int main()
{
bool MenuRepeat = true;
int UserSelection;
//MenuRepeat = TRUE;
do
{
cout << endl;
cout << "Welcome! Please pick one of the following options. \n1. Play BlackJack \n2. Play Hangman \n3. Play Snake \n4. Quit \nOption: ";
cin >> UserSelection;
cout << endl;
switch (UserSelection)
{
case 1:
{
blackjack bl;
bl.BlackJack();
break;
}
case 2:
{
hangman hm;
hm.Hangman();
break;
}
case 3:
{
snake sk;
sk.Snake();
break;
}
case 4:
{
MenuRepeat = false;
break;
}
default:
{
cout << "Incorrect Option. Please either play one of the games or Quit." << endl;
break;
}
}
} while (MenuRepeat);
return 0;
}
void blackjack::BlackJack()
{
cout << "Welcome to BlackJack!";
system ("pause");
}
void hangman::Hangman()
{
cout << "Welcome to Hangman!";
system("pause");
}
void snake::Snake()
{
cout << "Welcome to Snake!";
system("pause");
}