C
ChrisB
I have two pieces of code show below. The first contains a switch
statement. The second contains a text shown on the console application
screen. The simple menu shows up fine, I enter a number and the number
shows fine. But I do not get the console message printed, only the
standard press any key message followed by a program exit. This is
expected since there is essentially no more programming. Any ideas why
entering 1 will display 1 on the screen but not New Game message? and
any ideas how I can change this so that the messages in the switch
statement do show?
bool bStillPlaying = true;
int choice = 0;
while (bStillPlaying)
{
DrawMenu();
Console::WriteLine(S"Choose from Menu: ");
String * input = Console::ReadLine();
int choice = input->ToInt32(0);
return choice;
switch(choice)
{
case 1: Console::WriteLine(S"New Game"); break;
case 2: Console::WriteLine(S"Load Saved Game"); break;
case 3: Console::WriteLine(S"Save Game"); break;
case 4: Console::WriteLine(S"Set Options"); break;
case 5: Console::WriteLine(S"Adding Plants to Game"); break;
case 6: Console::WriteLine(S"Adding Herbivores to Game"); break;
case 7: Console::WriteLine(S"Adding Carnivores to Game"); break;
case 8: Console::WriteLine(S"Game Over Already?"); break;
}
}
with the call to
void DrawMenu()
{
Console::WriteLine(S" *****BioSphere Menu*****");
Console::WriteLine(S" * *");
Console::WriteLine(S" * 1) New Game *");
Console::WriteLine(S" * 2) Load Game *");
Console::WriteLine(S" * 3) Save Game *");
Console::WriteLine(S" * 4) Options *");
Console::WriteLine(S" * 5) Add Plants *");
Console::WriteLine(S" * 6) Add Herbivores *");
Console::WriteLine(S" * 7) Add Carnivores *");
Console::WriteLine(S" * 8) Quit *");
Console::WriteLine(S" * *");
Console::WriteLine(S" ************************");
};
statement. The second contains a text shown on the console application
screen. The simple menu shows up fine, I enter a number and the number
shows fine. But I do not get the console message printed, only the
standard press any key message followed by a program exit. This is
expected since there is essentially no more programming. Any ideas why
entering 1 will display 1 on the screen but not New Game message? and
any ideas how I can change this so that the messages in the switch
statement do show?
bool bStillPlaying = true;
int choice = 0;
while (bStillPlaying)
{
DrawMenu();
Console::WriteLine(S"Choose from Menu: ");
String * input = Console::ReadLine();
int choice = input->ToInt32(0);
return choice;
switch(choice)
{
case 1: Console::WriteLine(S"New Game"); break;
case 2: Console::WriteLine(S"Load Saved Game"); break;
case 3: Console::WriteLine(S"Save Game"); break;
case 4: Console::WriteLine(S"Set Options"); break;
case 5: Console::WriteLine(S"Adding Plants to Game"); break;
case 6: Console::WriteLine(S"Adding Herbivores to Game"); break;
case 7: Console::WriteLine(S"Adding Carnivores to Game"); break;
case 8: Console::WriteLine(S"Game Over Already?"); break;
}
}
with the call to
void DrawMenu()
{
Console::WriteLine(S" *****BioSphere Menu*****");
Console::WriteLine(S" * *");
Console::WriteLine(S" * 1) New Game *");
Console::WriteLine(S" * 2) Load Game *");
Console::WriteLine(S" * 3) Save Game *");
Console::WriteLine(S" * 4) Options *");
Console::WriteLine(S" * 5) Add Plants *");
Console::WriteLine(S" * 6) Add Herbivores *");
Console::WriteLine(S" * 7) Add Carnivores *");
Console::WriteLine(S" * 8) Quit *");
Console::WriteLine(S" * *");
Console::WriteLine(S" ************************");
};