Hi there, I am playing around with the terminal, early doors. I just added a little extra to get the user choice to print the particular choice as well as the level. I have chosen to set a string and pass it through to the StartGame, you’ll see below.
Is there a more efficient way of doing this? I was trying to use a CASE for this specific bit but couldn’t work it out. Not sure if would be any more efficient anyway. Any thoughts from more expert programmers out there? I am pretty new, though I have done the sister course, I am still learning to implement concepts on my own.
int level;
string gameName;
void OnUserInput(string input)
{
if (input == "1")
{
level = 1;
gameName = "NSA";
StartGame(gameName);
}
else if (input == "2") {
level = 2;
gameName = "CIA";
StartGame(gameName);
}
else if (input == "3")
{
level = 3;
gameName = "BPA";
StartGame(gameName);
}
else if (input == "menu")
{
ShowMainMenu();
}
else
{
Terminal.WriteLine("Please choose an option....");
}
}
private void StartGame(string gameName)
{
Terminal.ClearScreen();
Terminal.WriteLine("You have chosen level " + level);
Terminal.WriteLine("Let's break into the " + gameName);
}