Jump to content
  • Advertisement
Sign in to follow this  
terranman

C# Guess my number

This topic is 3686 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

My program totally works. But I want to add a cheat code that is my name, Alan. How do I make this work?... string Alan; if(guess == Alan) { //... }

Share this post


Link to post
Share on other sites
Advertisement
Exactly as you put it.


// for readability you should remember to put this at the top of your function
// that controls the game
string cheat = "Alan"; // in your code you forgot to initiallize the string

if (Guess.Equals(cheat))
{
// Do something...
}



if really depends on what you want to do, you could make the player win the game :


if (Guess.Equals(cheat))
{
won = true;
continue; // and then skip back to the beginning of the input loop and
// check to see whether the boolean variable won is true


}





Or you could make the program quit:


if (Guess.Equals(cheat))
{
Thread.Sleep(5000); // sleep for five seconds to allow the player to read the
// words. Im not sure if this works but it should be
// roughly the same as it is in java
System.exit(); // again, I'm not totally sure about this one, you'll have to
// check up on it
}



The possibilities are endless.

Share this post


Link to post
Share on other sites
My parents banned me from computer. I snuck on last night. My mom caught me as I was finishing up that last post :(

But... this is not the place for personal messages. By the way, it would be good not to put a thread with my first and last name smack dab on the front page of the forum. I will call you.

Share this post


Link to post
Share on other sites
My bad, I am a tard. The reason I did that is because u just posted, then I called u again because I knew u were there, but u didn't pick up. Sorry about that. It totally sucks that u got banned. :(

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!