This week's giveaway is in the Groovy forum. We're giving away four copies of Groovy Fundamentals video training course and have Ken Kousen on-line! See this thread for details.

As the error message says, the problem is in line 45 of DotComBust.java. The variable dotComToTest cannot be found because you don't define it anywhere.

For some reason you have a for-loop using an int x just before it, rather than for (DotCom dotComToTest : dotComsList) as in the book. Are you using a version of Java previous to 1.5? If so, you'll have to reference the list element using the index as you did a few lines above. If not, use the proper for-loop syntax as in the book.

jake dickens
Ranch Hand

Joined: Mar 23, 2011
Posts: 30

posted

0

i read the book again and it said for(DotCom dotComToTest : dotComsList) and all to it but it still says dotComsList.remove(dotComToTest) is still wrong

the book is wrong on it according to the online version of the code and the downloaded one has the GameHelper imported but does not show it in the book.

The error message you are getting is very explicit:

jake dickens wrote:DotComBust.java:45: cannot find symbol
symbol : variable dotComToTest
location: class DotComBust
dotComsList.remove(dotComToTest);

I've pulled out the method that this is referring to. The line numbers are now different, but line 45 in the original source code is equivalent to line 11 in the method shown below:

The error message is telling you that the first time it found the symbol dotComToTest was in line 45 in your code (line 11 above). Does that make sense to you now? Can you see anywhere else in that method where dotComToTest is mentioned (or, more importantly) defined?

i downloaded the chapter 6 and compared it to mine and what you said was to make sure but i'm saying the book is wrong cause the book told me dotComToSet not ToTest

Andrew Monkhouse
author and jackaroo
Marshal Commander

You are correct, by the way - there is a mistake in the book.

You can find the Errata for Head First Java online, and search for dotComToTest - the problem with the printed copy of the book is mentioned about a third of the way down the page.

As an aside, I recommend you look for errata anytime you look at any technical book.

Please put code between [code] and [/code] ubb code blocks, otherwise it is too hard to read, and you will find many people will simply move on to easier questions. I fixed your first post for you - you can hit the edit button on that post to see what I have done (or read the link in this post).

As I noted above, this error has been identified in the errata - you are advised to look at it.

Hi, jNewb here as well. I have built the java files like the book 2e + Errata has defined. My code compiles fine, but the output shows that the locationCells are not being set properly. I figure it is something to do with the placeDotCom setter or setLocationCells, but I also noticed that I don't see anything about setting the cells to an array with randomNum locs like in previous versions of the DotComGame. I will include the 3 java files as well as the printed output. All and any help is appreciated.

try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0

coord 1 = a0 coord 2 = a0 coord 3 = a0

try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0 try 0 used 0

coord 1 = a0 coord 2 = a0 coord 3 = a0

Enter a guess a0
hit
Enter a guess a0
hit
Enter a guess a0
Ouch! You sunk Pets.com : (
hit
Enter a guess a0
hit
Enter a guess a0
hit
Enter a guess a0
Ouch! You sunk eToys.com : (
kill
Enter a guess a0
hit
Enter a guess a0
Ouch! You sunk Go2.com : (
kill
All Dot Coms are dead! Your stock is now worthless.
It only took you 8 guesses.
You got out before your options sank.

Please don’t use such long lines inside the code tags; I have had to put new lines in to make them legible.

Steve Bradshaw, what do you mean about right to left? That sounds incorrect. What you actually mean is that the cast has a higher precedence that multiplication, so (int)a * b has to be changed to (int)(a * b). That is a common mistake; if you cast the random number to an int like the first attempt, you always get 0.