posted 17 years ago
In the Player class, number was initialized as int number = 0;, however right now it's not... . previous to p1.number, it calls p1.Guess(), which is supposed to assign a value to the variable 'number' on line 5 above.
right now the program will loop unless the first RNG also has a value zero, regardless of whether or not the Player.Guess() assigns a value to Player.number.
I've been reading ahead in the book, and it looks like int number should be in private, then have Guess return a number, or have a second function return a stored value... encapsulation. In this example, however, they don't use encapsulation since it hasn't been introduced yet.
OO Java Greenhorn... old school procedural programmer