OK, I read the next tutorial and did the switches. I got it to work IF MainMenu didn't go back to main. Well this is the code:
Code:
#include <iostream>
using namespace std;
int MainMenu(int pick);
int NewGame();
int Online();
int Exit();
int pick;
int main()
{
cout<<MainMenu(pick);
}
int MainMenu(int pick)
{
cout<<"Welcome to Super Game 2! \n";
cout<<"1. New Game \n";
cout<<"2. Online \n";
cout<<"3. Exit \n";
cout<<"Make A Selection: ";
cin>>pick;
switch (pick)
{
case 1:
cout<<NewGame();
break;
case 2:
cout<<Online();
break;
case 3:
cout<<Exit();
break;
}
}
int NewGame()
{
int pick;
cout<<"Sorry, Not Available In This Version! \n";
cin.get();
cout<<main();
}
int Online()
{
int pick;
cout<<"Sorry, Not Available In This Version! \n";
cin.get();
cout<<main();
}
int Exit()
{
cin.ignore();
cout<<"Thanks For Playing!";
cin.get();
}
Now what I want is the code to have MainMenu not have the switch statement. I want it so that Main has the switch statement and once you pick your variable at the MainMenu, it goes to Main and sees which case fits the variable pick. This is the code I messed around with:
Code:
#include <iostream>
using namespace std;
int MainMenu(int pick);
int NewGame();
int Online();
int Exit();
int pick;
int main()
{
switch (pick)
{
case 1:
cout<<NewGame();
break;
case 2:
cout<<Online();
break;
case 3:
cout<<Exit();
break;
default:
cout<<MainMenu(pick);
break;
}
}
int MainMenu(int pick)
{
cout<<"Welcome to Super Game 2! \n";
cout<<"1. New Game \n";
cout<<"2. Online \n";
cout<<"3. Exit \n";
cout<<"Make A Selection: ";
cin>>pick;
cout<<main();
}
int NewGame()
{
int pick;
cout<<"Sorry, Not Available In This Version! \n";
cin.get();
cout<<main();
}
int Online()
{
int pick;
cout<<"Sorry, Not Available In This Version! \n";
cin.get();
cout<<main();
}
int Exit()
{
cin.ignore();
cout<<"Thanks For Playing!";
cin.get();
}
That code, makes the mainmenu appear every single time. No matter what number you press! It could be 9 billion and it would still go to the main menu! Anybody know how to fix it?