Was trying to code for multiple passwords per level

I found this challenge confusing as I didn’t realize I was meant to code for a single password per level which was pretty easy as shown. However in the initial game design setup we were asked to come up with multiple passwords and so that was what I attempted. Initially was trying to check for which level in an if loop and then within that nested another loop to check for specific passwords. Bit of a mess really as I think an array or something similar would be needed. Still here’s the code in case anyone has any thoughts.

void StartGame( )
    {
        currentScreen = Screen.Password;
        Terminal.WriteLine("You have chosen level " + level);
        Terminal.WriteLine("Please enter your password " );
        CheckPassword(level);

    }

    void CheckPassword(int input)
    {
        if (input == 1)
        {
            if (password == "Moon")
            {
                Terminal.WriteLine("PASSWORD ACCEPTED CONGRATS!");
            }
            else if (password == "Space")
            {
                Terminal.WriteLine("PASSWORD ACCEPTED CONGRATS!");
            }
            else if (password == "Rocket")
            {
                Terminal.WriteLine("PASSWORD ACCEPTED CONGRATS!");
            }
            else if (password == "Earth")
            {
                Terminal.WriteLine("PASSWORD ACCEPTED CONGRATS!");
            }
            else if (password == "HAL")
            {
                Terminal.WriteLine("PASSWORD ACCEPTED CONGRATS!");
            }
            else
            {
                Terminal.WriteLine("***PASSWORD FAILED OPENING AIR LOCK***");
            }
        }
        else if (level == 2)
        {
            if (password == "SpaceStation")
            {
                Terminal.WriteLine("PASSWORD ACCEPTED CONGRATS!");
            }
            else if (password == "Satellite")
            {
                Terminal.WriteLine("PASSWORD ACCEPTED CONGRATS!");
            }
            else if (password == "DownLink")
            {
                Terminal.WriteLine("PASSWORD ACCEPTED CONGRATS!");
            }
            else if (password == "Xenomorph")
            {
                Terminal.WriteLine("PASSWORD ACCEPTED CONGRATS!");
            }
            else if (password == "SpaceSuit")
            {
                Terminal.WriteLine("PASSWORD ACCEPTED CONGRATS!");
            }
            else
            {
                Terminal.WriteLine("***PASSWORD FAILED OPENING AIR LOCK***");
            }
        }
        else
        {
            Terminal.WriteLine("***PASSWORD FAILED OPENING AIR LOCK***");
        }
    }

I kinda did something similar. Instead I made only one password.

Privacy & Terms