• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Head First Java 2nd Edition - Page 112, chapter 5 - Gamehelper/simpledotcom/simpledotcomgame

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've typed up the code exactly as is written in the book, however, i keep getting errors when trying to compile.

Below is the copy of what i've typed up.




Could anyone with a sharp eye, knowledge and with a copy of the book point to where exactly I'm going wrong?

Thank you so much!
 
john pep
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've changed the Helper object instantiation, was previously upper case.
Still doesn't compile.
 
author & internet detective
Posts: 41071
848
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've added code tags to make the post more readable.

At a glance, you are missing imports. You need "import java.io.*;" at a minimum up top. (I do see it further down, but it needs to be on top if this is all in one file.) After adding that, can you post what compiler errors you get?
 
john pep
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The SimpleDotComGame reaches the end of file while parsing, I'm trying to see if it's been closed properly.

I've added the import at the top thank you, the errors have been reduced by 1, 12 more to go!

Edit: the if statement in the first class used a colon, instead of the semi colon. this has now been changed. Errors are down to 11 now.
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi. You have confused ( with { and { with ( a few times.
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

john pep wrote:The SimpleDotComGame reaches the end of file while parsing, I'm trying to see if it's been closed properly.


I don't understand that at all. You mean, you're getting this as a compiler message for SimpleDotComGame.java?

Errors are down to 11 now...


And as Jeanne said: we can't do much unless we see them (the exact messages, please). Unless you're happy to just keep posting your error count.

Winston
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys,

I know this is quite an old thread but I am also stuck with the same problem. My simpleDotComGame doesn't want to compile for any reason



Hope you guys can help. I have the other classes in the same directory but in different class files. Also my IntelliJ Idea tells me that randomNum is never used, but I just declared it there. I don't get it.
 
Marshal
Posts: 75629
354
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

Please post the error message; we can only help if we know the details of the problem.
Something else: never write == true or == false. Both are poor style and error‑prone; you might write = by mistake.
Never
while (isAlive == true) ...
Always
while (isAlive) ...
Never
while (isAlive == false) ...
Always
while (!isAlive) ...
 
Binh Phan
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the warm welcome 😁

I wanted to post the error message but I couldn‘t find the edit button 😅
I already figured out the mistake I did. Te problem was that instead of {} in the int[], I used ().
But thanks for your tip though. I will try to keep that in mind 😃
 
Campbell Ritchie
Marshal
Posts: 75629
354
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Binh Phan wrote:Thanks for the warm welcome 😁

That's a pleasure

. . . I couldn‘t find the edit button 😅

We have hidden it. You can post the error message as a new post.

. . . instead of {} in the int[], I used (). . . .

I missed that. Sorry. I shall have to put my reading glasses on
 
The only thing that kept the leeches off of me was this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic