What i did in this solo

I pretty much had all the basic knowledge needed to write it without problems, thanks to the previous lectures, but still i struggled, not because of lack of knowledge, but because when i come in front of wall of code i get overwhelmed and i stop thinking. What i did was, i checked the old functions we did in previous lectures and it hit me. Why don’t i make a new method and call it via the OnUserInput method from before, and so i did. IF anyone is interested, here is the method:

void Checkingpass(string input)
{
    
    if (input == "password1" && level == 1)
    {
        Terminal.WriteLine("congrats");
        currentScreen = Screen.Win;
    }
    else if (input == "password2" && level == 2)
    {
        Terminal.WriteLine("congrats");
        currentScreen = Screen.Win;
    }
    else {
        Terminal.WriteLine("Wrong password");

    }
}

Also in the OnuserInput method i added:

else if (currentScreen == Screen.WaitingForPassword) {
        Checkingpass(input);
    }
1 Like

Hey Nickolas,

Way to push past the feeling of being overwhelmed!

Love how you went back to the previous lectures to overcome your struggles.

Nice job!

Very nice and simple! Good work!

I wanted to do it whis way, but I didn’t figure out the syntax. I tried (input == “password1”) && (level = 1)

Privacy & Terms