• Post Reply Bookmark Topic Watch Topic
  • New Topic

question about "Head First Java" book  RSS feed

 
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everybody,
This is my first posting to the javaranch site. I'm working through the "Head First Java" book and am learning a lot and can't wait to get back to it each time I put it down. But I am wondering if anyone who is using the book can tell me their "mental approach" to solving the pool puzzles. As they get more complicated I find it difficult to figure them out without actually writing the program and "hacking". In other words, trying things until they work.
This may be an obscure question but does anyone have any pointers on how to think about these problems without writing the code and some trial-and-error? I feel like I'm cheating doing it the way I'm doing it. An example that I just did is p. 89 in Chapter four.
Thanks in advance.
Barbara (farmkitty)
 
Sheriff
Posts: 6450
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi "farm kitty",
Welcome to JavaRanch! We don't have too many rules here, but one that we do have is our JavaRanch Naming Policy. Please change your display name to comply with this policy. Thanks in advance, and we look forward to seeing you 'round the Ranch!
 
author
Sheriff
Posts: 8954
17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This post makes me very happy
First off, while I'm quite fond of them, I have to reiterate what we say on page xxvii:
'These puzzles are meant for puzzlers, and you probably already know if you are one. If you're not sure, we suggest you give some of them a try, but whatever happens, don't be discouraged if you can't solve a puzzle or if you simply can't be bothered to take the time to work them out.'
We really feel the exercises are VERY important, they don't fall into the same category as the puzzles. The puzzles seem to elicit a lot of response. Some people love 'em, some people hate 'em. I'd say if you enjoy puzzles, some of these are pretty good, have fun. If you hate puzzles, then make up your own little project to work with the new Java stuff covered in that chapter. To some degree it's about 'time on task', and you could say that the puzzles are (I hope), a fun way to spend time on the task.
Now to your original question: We tried to design these puzzles so that there is no one, surefire way to solve them. However, I will give you a few ideas:
- Often it helps to work backwards from the output
- It almost NEVER works to go top down
- Solving a given puzzle ALWAYS has do to with applying concepts from the chapter
- For me, these are great 'whole brain' activites. I kind of get everything loaded into (in my case limited amount of), brain RAM. As I think about the puzzle I'll start to develop a 'tentative facts list' - things I think I know about what's going on. (I write these 'tfs' on a side list.) I don't know of anyway to eliminate a little trial and error, that's just part of most puzzles, but it can be reduced, and it's my hope that you can do them all with pencil and paper, maybe right in the book! (gasp!)
Let us know how you do!
-Bert
[ September 30, 2003: Message edited by: Bert Bates ]
 
Barbara Norway
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks to the author for taking the time to post such a helpful reply. For one thing I had forgotten about the puzzlers being "more optional" than the exercises. I also appreciate the pointers on how to approach the problems.
I am now on Chapter 5 (p 110) and, although the book mentions that there is Ready-bake code for Chapter 5 I cannot find it on the headfirstjava site nor a mention in the errata that it's not available. I checked out Chapter 6's ready-bake code, which uses different classes than Chapter 5 but after compiling the three java files as instructed in the Ch6ReadMe file, I am unable to get any other result than miss regardless of how many (well I did only try about 30 guesses all-in-all) guesses I entered. Am I missing something?
Thanks in advance for any and all help.
Barbara
P.S. I have the original May printing of the book but have consulted the errata and updated the book.
 
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that the code on page 110 (the GameHelper class) IS the ready bake code.
The chapter 6 stuff worked fine for me. Exactly which 3 files are you trying to compile? I don't know where the ReadMe is.
 
Barbara Norway
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I'll try just typing the code in for Chapter 5 and running it with the two classes I already typed in for that Chapter. Thanks.
I'm using DotComBust.java, GameHelper.java,and DotCom.java. I compile the three separately and run them from DotComBust. No runtime nor compilation errors but just keep getting miss and nothing else. I got the code from the headfirstjava.com site. I downloaded the jar file and extracted it. Under the chapetr-6 directory there was a readme file along with the three java files. I should probably do chapter 6 before jumping the gun here and asking for help. Perhaps there are some modification of the files that I should perform while working through the chapter. My apologies. I was working through chapter 5 and asked this question prematurely as I thought there was a "ready-bake" (read: no typing) example in the jar file for chapter 5.
Sorry.
I'll do chapter 6 tomorrow and probably see the solution to the problem.
Barbara
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bert Bates wrote: We tried to design these puzzles so that there is no one, surefire way to solve them. However, I will give you a few ideas:
- Often it helps to work backwards from the output
- It almost NEVER works to go top down
- Solving a given puzzle ALWAYS has do to with applying concepts from the chapter
- For me, these are great 'whole brain' activites. I kind of get everything loaded into (in my case limited amount of), brain RAM. As I think about the puzzle I'll start to develop a 'tentative facts list' - things I think I know about what's going on. (I write these 'tfs' on a side list.) I don't know of anyway to eliminate a little trial and error, that's just part of most puzzles, but it can be reduced, and it's my hope that you can do them all with pencil and paper, maybe right in the book! (gasp!)
[ September 30, 2003: Message edited by: Bert Bates ]


Thanks Bert!

I'm assuming that putting the code into a text editor and then compiling different combinations via trial and error is okay?
 
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Busby wrote:... I'm assuming that putting the code into a text editor and then compiling different combinations via trial and error is okay?

Welcome to the Ranch!

Some trial and error is probably inevitable to test parts of your code, but that should not be your overall approach. The purpose of these exercies is for you to reason through the problem and apply what you learned in the chapter -- not just guess. Does that make sense?
 
David Busby
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
marc weber wrote:
David Busby wrote:... I'm assuming that putting the code into a text editor and then compiling different combinations via trial and error is okay?

Welcome to the Ranch!

Some trial and error is probably inevitable to test parts of your code, but that should not be your overall approach. The purpose of these exercies is for you to reason through the problem and apply what you learned in the chapter -- not just guess. Does that make sense?


Thanks Marc.

It does make sense. Any other tips on using reason to solve pool puzzles?
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Busby wrote:... Any other tips on using reason to solve pool puzzles?

As Bert said above (in 2003), "Often it helps to work backwards from the output ... It almost NEVER works to go top down."

To me, this means start with the desired result, and ask yourself, "What did the chapter just cover that produces results like this?" Once you have identified that piece, work backwards again, and ask yourself, "What do I need to make that piece work?" And so on, until you've worked backwards to the input.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!