• Post Reply Bookmark Topic Watch Topic
  • New Topic

Would love some input.  RSS feed

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello again guys,

I'm working on chapter 5 of the Headfirst Java book, and I believe I'm a bit stuck.

On page 107, the sharpen your pencil section of the SimpleDotCom game, I am completely lost.

I understand everything in the previous chapters but when it comes to writing this prepcode, I don't even know how to start. It's like I'm thinking of it in components, but when it comes to writing even just psuedocode, nothing whatsoever comes to mind.

From what I understand, these sharpen your pencil exercises are of critical importance and you should have the skills to complete them when you reach them. I feel completely unprepared. Should this not be the case? I honestly can't see where I'm going wrong.

If anybody can think of anything to help me make this come together, I'd really appreciate it.
 
Saloon Keeper
Posts: 7993
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Matthew.

You're kinda shooting yourself in the foot by not specifying the troubles you're having. I don't think most here own the book (or maybe they do, and it's just me).

Why don't you tell us about the exercise, and what exactly you don't understand?
 
Matthew Taheri
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that the issue is sort of specific to the flow of the book but I'll try to describe it. I appreciate any offer of help.

Basically they give you a few lines of prepcode and your assignment is to complete the rest. The code is supposed to pertain to writing the game class which simulates a very simple version of battleship (one ship occupying 3 predefined cells in a one row grid array of seven cells).

They've already laid out the object class. I'm left to figure out the rest on my own. Their question is extremely vague and whenever I think I'm on the right track, I look down to see part of what I'm doing covered differently in a completely different part of the code. I just cant figure out how what I'm doing is supposed to be different from what has already been laid out.
 
Stephan van Hulst
Saloon Keeper
Posts: 7993
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So can you show us what you've done so far?
 
Ranch Hand
Posts: 434
7
Android Open BSD Slackware
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Matthew Taheri wrote:I think that the issue is sort of specific to the flow of the book but I'll try to describe it. I appreciate any offer of help.

Basically they give you a few lines of prepcode and your assignment is to complete the rest. The code is supposed to pertain to writing the game class which simulates a very simple version of battleship (one ship occupying 3 predefined cells in a one row grid array of seven cells).

They've already laid out the object class. I'm left to figure out the rest on my own. Their question is extremely vague and whenever I think I'm on the right track, I look down to see part of what I'm doing covered differently in a completely different part of the code. I just cant figure out how what I'm doing is supposed to be different from what has already been laid out.


HI Mattew the sharpen your pencil is only to sharp your mind, to focus your attention, i am newbe as well, but it is clear that you cannot be a scrum master or know XP methodologies as suggested if you did not learn another language before and you can reason in terms of Object Oriented Programming. SO not worry just try to guess, everything will be clear later es try catch.. arraylist and so on, just challenge yourself playing the game.
 
Matthew Taheri
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stephan van Hulst wrote:So can you show us what you've done so far?


Honestly, other than the preformatted lines, nothing.
 
Matthew Taheri
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Giovanni Montano wrote:
Matthew Taheri wrote:I think that the issue is sort of specific to the flow of the book but I'll try to describe it. I appreciate any offer of help.

Basically they give you a few lines of prepcode and your assignment is to complete the rest. The code is supposed to pertain to writing the game class which simulates a very simple version of battleship (one ship occupying 3 predefined cells in a one row grid array of seven cells).

They've already laid out the object class. I'm left to figure out the rest on my own. Their question is extremely vague and whenever I think I'm on the right track, I look down to see part of what I'm doing covered differently in a completely different part of the code. I just cant figure out how what I'm doing is supposed to be different from what has already been laid out.


HI Mattew the sharpen your pencil is only to sharp your mind, to focus your attention, i am newbe as well, but it is clear that you cannot be a scrum master or know XP methodologies as suggested if you did not learn another language before and you can reason in terms of Object Oriented Programming. SO not worry just try to guess, everything will be clear later es try catch.. arraylist and so on, just challenge yourself playing the game.


You have saved me a weeks worth of anguish. Thanks much.
 
Giovanni Montano
Ranch Hand
Posts: 434
7
Android Open BSD Slackware
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Matthew Taheri wrote:

You have saved me a weeks worth of anguish. Thanks much.


you are welcome, but I would suggest you to do the exercises at the end of chapters.
when you will be to the try catch chapter,everything will be clear.
BTW as we have internet and this forum, we are sitting pretty, you will find the juke box that is equally challenging starting from the GUI and try catch chapters.

personally i follow a triple approach: 1 I go further with more complex things 2 i repeat from the beginning 3) i do causal repetitions, read this forum, do some small code, follow some android tutorial, read other books as the certification manual to acquire the slang.

as rule of thumb here is my flow:
read head first
if not understand then think

if think>3 then read certification manual
if certification manual != learn then search your favorite internet engine
else
think again
ask JavaRanch



 
Marshal
Posts: 56600
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A better flowchart would be
think→think→think→askOnJavaRanch
 
Giovanni Montano
Ranch Hand
Posts: 434
7
Android Open BSD Slackware
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:A better flowchart would be
think→think→think→askOnJavaRanch


for (i=1;i<10^10;i++){
System.out.println("I agree");
}


 
Bartender
Posts: 2087
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Giovanni Montano wrote:for (i=1;i<10^10;i++){
System.out.println("I agree");
}

Do you realize that this won't compile ? (operator precedence)
And even if it did compile, it would not print a single "I agree" as 10^10 is equal to 0 .
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!