Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

i love you

Name: Anonymous 2009-03-17 17:54

//validates if the guess is a valid guess in length
while (SecretCodeDigits == 5 && (userGuess < 10000 && userGuess > 99999)|| (SecretCodeDigits == 4 && (userGuess < 1000 && userGuess > 9999))||(SecretCodeDigits == 3 && (userGuess < 100 && userGuess > 999)));
//excessively long condition                    {
                        System.out.println("please enter a valid guess that is " + SecretCodeDigits + " digits long.");
int userGuess = keyboard.nextInt();
}

It says i have a duplicate local variable for "userGuess".
how can i fix this?

Name: Anonymous 2009-03-17 20:11

Jesus fucking Christ. >>3 already solved your problem, but since you're apparently a dense faggot:

while (SecretCodeDigits <= 5 && SecretCodeDigits => 3) {
    System.out.println("Please enter a valid guess that is " +
                       SecretCodeDigits + " digits long.");
    userGuess = keyboard.nextInt();
}


Note what's been fixed:

1. Your condition was retarded. >>3's optimisation was probably too optimistic, so mine is exactly equivalent except not dumb.

2. You had a semicolon after your while(). Infinite loops aren't fun for anyone, asshole.

3. I capitalised ``please''. Not related to the code, just common fucking courtesy.

4. The thing the compiler complained about: you redeclared userGuess when you clearly already had a variable named that, as evidenced by the fact you used it in your condition.

I did not fix the problem that your code doesn't actually do what the comment says it does. I assumed you just suck at writing comments, so I removed it.

And fuck you for using Java.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List