• Post Reply Bookmark Topic Watch Topic
  • New Topic

help in debugging  RSS feed

 
Jose Kampilan
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.

I've been typing the code for the Sink-a-dotcom game from the Head First:Java book. I encountered problems on compile time though.

First, compared what i typed with the one in the book. when i didnt find any difference (except for bracket placements and spacing) in the two, i downloaded the code from the site and tried to compile the downloaded code (it worked). i tried to check whether i typed something wrong or forgot to enter a line and this time compared it to the downloaded code. Again, i didnt find anything different between the two.

And that's my question, what did i do wrong?

I encounter the problem on both of the source files for the game.

Here's the error for the Game helper file (changed the directory):



And here's the error for the main Dot Com Bust file solved


Here's the code i copied from the book followed by the code downloaded from wickedlysmart.com (the problem probably is in the first few lines but i added the whole things just in case) :

Game Helper file:

TYPED



DOWNLOADED



Dot Com Bust file: solved
 
Greg Brannon
Bartender
Posts: 563
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The error message is very helpful. Compare line 5 of Typed to line 4 of Downloaded as shown in the last 2 files posted.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12562
49
Chrome Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you tell me, where EXACTLY in your code, you define the Gamehelper class?

(remember, Java is case sensitive)
 
Jose Kampilan
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Greg Brannon: thanks. cant believe i didnt see that. it was staring at me in the face. changed the h to H and the DotComBust file compiled and ran.

@fred rosenberger: not sure about this: is it the whole gamehelper file? from line 4 to line 86?

changed the directory for the game helper file from the "holding" folder to the main "JavaProjects" folder. Still gave me the same error though



the next thing i did was to copy-paste that part of the code from "downloaded" one to the "typed" one. this time it gave a different error.



i checked whether the placeDotCom class was missing a bracket. but it looks like the all the brackets for that class are complete.
 
R. Jain
Ranch Hand
Posts: 375
1
Java Python Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jose Kampilan wrote:@Greg Brannon: thanks. cant believe i didnt see that. it was staring at me in the face. changed the h to H and the DotComBust file compiled and ran.

@fred rosenberger: not sure about this: is it the whole gamehelper file? from line 4 to line 86?

changed the directory for the game helper file from the "holding" folder to the main "JavaProjects" folder. Still gave me the same error though



the next thing i did was to copy-paste that part of the code from "downloaded" one to the "typed" one. this time it gave a different error.



i checked whether the placeDotCom class was missing a bracket. but it looks like the all the brackets for that class are complete.


Did you noticed that, you are using: - toLowercase() instead of toLowerCase() [* C capital ]

This is the general naming convention in Java. Edit it to see the desired output.
 
Jose Kampilan
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@R. Jain: wow thanks. changed the cases and it worked. i really need to be careful with the cases (that's the second time now).
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!