I would like the Hacker game to run through all the scrambled words in each level before going to the “Win” screen. I’m trying to use a “for” loop, but I’m really not getting anywhere.
Hopefully I’m on the right path, but does anyone know how this could be done?
I guess i’m not sure where to actually place the loop.
1st I initialized a variable: win up at the top on line 10:
bool win = false;
Then I changed the Ask For Password to include the for loop:
void AskForPassword()
{
currentScreen = Screen.Password;
Terminal.ClearScreen();
for (int k = 0; k <= level01Passwords.Length; k++)
{
Password = level01Passwords[k];
//SetPassword();
Terminal.WriteLine(menuHint);
Terminal.WriteLine(" ");
Terminal.WriteLine("Level: " + level);
Terminal.WriteLine("");
Terminal.WriteLine("Enter your password. Hint: " + Password.Anagram());
if (k == level01Passwords.Length)
win = true;
}
Lastly I tried to change the CheckPassword:
void CheckPassword(string input)
{
if (input == Password) & (win == true)
{
DisplayWinScreen();
}
else
{
AskForPassword();
}
}
I’ve worked on this a while… any help would be greatly appreciated!!