The Solo code section, or I stumbled, I went whaaaat? I got something to work

How to order and name things is still a challenge.

Coming up with the solution was probably more guessing than actual understanding at this juncture. I suspected that Ben’s solution was going to be way different from mine while I was working on the problem, and yes the way he did it makes more sense now. I was in the ballpark when using a Boolean occurred to me and just went that route.

Was thrilled to come up with a Boolean to test for the password and level.

I am clear on namespace, classes, functions, messages, and variables. I really had to stop and go over the structure of C# earlier in the month, as the naming scheme was obfuscating the structural differences for awhile. With void in front of everything it kind of blends together.

Overall it was a good object lesson.

The two sections I used for testing password:

void OnUserInput(string input)
{
if (input == “menu”)
{
ShowMainMenu();
}

    else if (currentScreen == Screen.MainMenu)
    {
        RunMainMenu(input);
    }

    else if (currentScreen == Screen.Password)
    {
        EnterPassword(input);
    }
}

and…

void EnterPassword(string input)
{
if (input == “dog” && level == 1)
{
Terminal.WriteLine(“Password successful.”);
}
else if (input == “cat” && level == 2)
{
Terminal.WriteLine(“Password successful.”);
}
else
{
Terminal.WriteLine(“Please try again.”);
}
}

Privacy & Terms