Hello again!
I have successfully typed in, compiled and run the guessing game.
However, looking at the code there are a few things I am unsure about . I know that the authors say that not everything should be clear at this stage in the book, but, following my own learning style, I think I'm seeing connections and clarification here would confirm that I'm constructing the ideas correctly!
Here's the code for the three classes: GameLauncher.class, Player.class and GuessGame.class:
Note 1: As I see it here, an instance of the class GuessGame has been created, and it has been given the variable name 'game'.
Note 2: But here, instances of Player called p1, p2 and p3 are simply declared, without yet having been explicitly defined. This only comes at Note 3:
Note 3: Here three instances of the class Player are created and assigned the names p1, p2 and p3.
I replaced the code in the first few lines of the GuessGame code to the following, and re-compiled it, and everything still seemed to work satisfactorily, so I am not sure why the extra code lines included in the Head First Java text were deemed necessary.
I even don't understand why, under the text book version, there is NOT a compile error, as it would seem to me that the statements
are being included before new instances have been created.
Rather confused!
I hope my explanation of an apparent contradiction in my eyes of how instances are declared/defined/created is clear to you!
Mike
[ January 15, 2006: Message edited by: Mike Hudek ]