Stephan van Hulst wrote:You probably haven't specified the classpath, so the compiler doesn't know where to look for game\GuessGame.java.
In the command line, go to the folder that contains the game folder, and try: "javac -cp . game\GuessGame.java"
C:\Users\Sonny\Documents\Head1stJava\src>javac -cp . game\GuessGame.java
game\GuessGame.java:24: error: cannot find symbol
p1.guesse();// call each players guess method
^
symbol: method guesse()
location: variable p1 of type Player
game\GuessGame.java:25: error: cannot find symbol
p2.guesse();
^
symbol: method guesse()
location: variable p2 of type Player
game\GuessGame.java:26: error: cannot find symbol
p3.guesse();
^
symbol: method guesse()
location: variable p3 of type Player
game\GuessGame.java:46: error: cannot find symbol
p3isRight = true;
^
symbol: variable p3isRight
location: class GuessGame
game\GuessGame.java:49: error: cannot find symbol
if (p1isRight || p2isRight || p3isRight) {
^
symbol: variable p3isRight
location: class GuessGame
game\GuessGame.java:54: error: cannot find symbol
System.out.println("Player three got it right? " + p3isRight)
^
symbol: variable p3isRight
location: class GuessGame
6 errors
Steven Bruton wrote:You have 6 compile errors in your code, that is why it will not compile.
Just some spelling errors;
The boolean p3isRIght should be p3isRight,
You made a call to guesse() 3 times but the method name is guess().
run:
I'm thinking of a number between 0 and 9...
Number to guess is 1
I'm guessing 6
I'm guessing 3
I'm guessing 2
Player one guessed 6
Player two guessed 3
Player three guessed 2
Players will have to try again.
Number to guess is 1
I'm guessing 3
I'm guessing 0
I'm guessing 1
Player one guessed 3
Player two guessed 0
Player three guessed 1
We have a winner!
Player one got it right? false
Player two got it right? false
Player three got it right? true
Game Over!
BUILD SUCCESSFUL (total time: 1 second)
Nick de Waal wrote:
Nick de Waal wrote:
C:\Users\Sonny\Documents\Head1stJava\test\classes\com\headfirst>cd game
C:\Users\Sonny\Documents\Head1stJava\test\classes\com\headfirst\game>java GameLauncher
Exception in thread "main" java.lang.NoClassDefFoundError: GameLauncher (wrong name: com/headfirst/game/GameLauncher)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
Nick de Waal wrote:Hi Henry,
Actually I did mention it although I was rather vague, my apologies,
so here is a copy of the code as it stands:
Steven Bruton wrote:You compiled it successfully then, your problem is running it.
Try this;
Navigating back to this directory: "C:\Users\Sonny\Documents\Head1stJava\test\classes\com\headfirst",
From that directory try this command "java game/GameLauncher".
Nick de Waal wrote:Henry that's it!!
Thank you,
if I may ask, would you be able to give me a small explanation as to what is going on? I mean, using the "." instead of what I was doing.
Or maybe point me to an explanation on the web.
It would be much appreciated
thanks again
Don't get me started about those stupid light bulbs. |