Sign in to follow this  
terranman

C# Guess my number

Recommended Posts

terranman    100
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
jdub    459
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
jdub    459
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
terranman    100
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this