Yong Lee wrote:So I'm a little stumped...the following code produces this output:
triangle 0, area = 4.0
triangle 1, area = 10.0
triangle 2, area = 18.0
triangle 3, area = 28.0
y = 4, t5 area = 343
What has me stumped is the last line of output...I understand that both t5 and ta[2] are pointing to the same Triangle object, and that by setting ta[2].area = 343, t5.area will also = 343. But where does "y = 4" come from - if y = x, and x is set as 27, where is the value changed to 4? Any help would be appreciated, thanks!
[ May 26, 2008: Message edited by: Campbell Ritchie ]
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)
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