• Post Reply Bookmark Topic Watch Topic
  • New Topic

Head First Guessing Game Problem  RSS feed

 
Tim Dunphy
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey all,

Having trouble getting the "Guessing Game" example from HF Java chapter 2 going.

The "GuessGame" class doesn't compile. Seems it can't find the "Player" class, even tho that compiled without a problem.

Here's the error I get:



The "game" is made of a few classes / files. The point is to generate a random number and to have an automatically created (non-human) "player" guess the number.

The "GuessGame" class




The "Player" class:


The Game Launcher class:


That's it! Seems simple. But I'm not sure what's causing the error. Can I get a "nudge" in the right direction?
 
Winston Gutkowski
Bartender
Posts: 10573
65
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Dunphy wrote:The "GuessGame" class doesn't compile. Seems it can't find the "Player" class, even tho that compiled without a problem.

Because it doesn't "need" anything else in order to work.

Have a look at this tutorial page and see if it helps.

Winston
 
Campbell Ritchie
Marshal
Posts: 55793
164
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you copy the code by hand or download it?
If you downloaded the code, it will have a package name, which you don't need at this stage and may cause you confusion. Go to the very top of the file and change
package chapter 03;
to
// package chapter03;
save the files and try again.
 
Tim Dunphy
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Did you copy the code by hand or download it?
If you downloaded the code, it will have a package name, which you don't need at this stage and may cause you confusion. Go to the very top of the file and change
package chapter 03;
to
// package chapter03;
save the files and try again.


Yup! Commenting out that package line was what does the trick! Turning:


To:


allows the game to compile:



And now, thankfully, the game runs!



Thanks for the help!



 
Campbell Ritchie
Marshal
Posts: 55793
164
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome

You won't believe this, but we have all seen the same problem before.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!