[SOLVED]Menu command doesn't work properly

My Terminal Hacker is Complete if not for this one bug. Every time I use “menu " command. It takes me back to main menu but at the same time it shows I have not input a valid level selection in my main menu i.e “Choose a valid level” or in my case " Lo0k I’m coRrupted En0ug#, try again”, buddy I haven’t tried to put one yet! I’ll put my code below for better understanding.

This is the C# file

Hi Farzan,

Have you already compared your code to the Lecture Project Changes which can be found in the Resources of this lecture?

Oh yes multiple times most differences we have is in the background story not in the actual code I even changed my code to match his

The last 2 lines must come if I put in a wrong code but they are already there when I return using menu

I checked your script, and it makes sense that the last two lines appear. If RunMainMenu gets called, if IsValidLevel is false and if the input string is neither “666” nor “007” nor “123”, the else block at the bottom of that method gets executed.

else
{
    Terminal.WriteLine("Lo0k I'm coRrupted En0ug#");
    Terminal.WriteLine("Try @ga!n");
 }

hey I found the solution on our Udemy Q&A
in the OnUserInput()

void OnUserInput(string input)
    {
         if (input == "menu")
        {

            Terminal.ClearScreen();
            ShowMainMenu();
        }
        else if (input == "hey")// changed if to else if and problem solved
        {
            Terminal.WriteLine("wassup") ;

        }
        else if (CurrentScreen == Screen.MainMenu)
        {
            RunMainMenu(input);
        }
        else if (CurrentScreen == Screen.Password)
        {
            CheckPassword(input);
        }

    }

Since there was another if, it started checking again and thus the error

Thanks for the support

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms