mardi 14 juillet 2020

Is there a way to make an if statement nil in C#?

static void Main(string[] args)
        {
            int Guesscount = 3;
            string SecretWord = "pen";
            string guess = "";
            Console.WriteLine("If you are stuck then type !Hint for a hint, good luck!");

            while (guess != SecretWord)
            {
               
                Console.WriteLine($"you have {Guesscount} tries left");
                Console.Write("Guess the word:");
                guess = Console.ReadLine();
                Guesscount--;

                if (Guesscount == 0)
                {
                    Console.WriteLine("You lose :P");
                    break;
                }
                if (guess == "!Hint")
                {
                    Guesscount++;
 

                       Console.WriteLine("Hint: It is used to write on paper.");
                        
                    }
                }
                Console.Write("You Win!");
                   
                
            }
        }
    }

pretty simple, but I was wondering if there was a way so that once they use a hint the if statement becomes nil and can't be used again. So I used this in a C# tutorial I found online and I wanted to add some new things for myself. So this hint as you can see gives the player a hint on the mystery word. I was wondering if you can make the if statement that's being passed nil or null so it doesn't get executed again if the player types !hint again. P.S. I don't know the difference between nil or null sry if I made anyone mad¯_(ツ)_/¯. Any help would be nice thx.

Aucun commentaire:

Enregistrer un commentaire