justin villanueva

Greenhorn
+ Follow
since Feb 02, 2011
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by justin villanueva

Pramod P Deore wrote:Then you must have to declare variable size as

int size;


D'oh! I knew that, had the wrong variable! Its working now Thanks all!

Now, maybe one more question. Why didn't it return an int in the first place?

In the example from the book, instead of receiving a size for the kitty from the user, the size is added into the code (one.setSize(70); for example)
13 years ago

Pramod P Deore wrote:write method as



instead of


Now it says cannot find symbol and points to size
13 years ago

Bear Bibeault wrote:The compiler doesn't like to be lied to. In this method:
you tell the compiler that you will be returning an int, but then don't. This ticks it off.

So either return an int, or tell the compiler that you don't intend to return anything (which is probably what's best) by declaring the return type as void.


How do I declare the return type as void?
13 years ago
Hiya, I have some code that I'm just messing around with while reading Head First java. So this really isn't serious code.

Now my problem is that I keep getting the error "Missing return statement" and it points to a }

So heres my code



Pretty much it asks for the size of a kitty and then it runs the if statement.

Any help would be much appreciated
13 years ago

Campbell Ritchie wrote:

justin villanueva wrote: . . . I don't see the SimpleDotComGame.java in there, all I see is DotCom.java, DotComBust.java, and GameHelper.java. . . ..

Did you read the ReadMe file?


Yeah I did, I fixed the problem. But chap6 is for a somewhat different program (more of an expanded version of the chap 5 program) What I wanted was to get the chap 5 program working correctly before I move to chap 6.
13 years ago
alright I have it figured out now! This is for people that have the book and are working on the SimpleDotCom game and are having the same trouble.

On Page 110 when they say "The Game's main() method, the seem to have made a mistake and didn't mention that the chunk of code is supposed to be the SimpleDotComGame.java and on the download page, the main method is in a file called Game.java.

You have to put the main method on page 110 between



In the end you'll have the SimpleDotCom.java, the SimpleDotComGame.java, and GameHelper.java.

Thanks for all the help
13 years ago

Campbell Ritchie wrote:

justin villanueva wrote: . . . isn't in the chap 5 download files.

I found it here, but for some peculiar reason it appears to be in the chapter 6 folder. There is a "ReadMe" file, too, which tells you how to run it.


I don't see the SimpleDotComGame.java in there, all I see is DotCom.java, DotComBust.java, and GameHelper.java.

I appreciate all the help btw. I just wanna get through chap 5 before I move to chap 6.
13 years ago

Mihai Lita wrote:Hey,
The SimpleDotCom class doesn`t have a main method. You must compile and run SimpleDoComGame file
I hope it helps


the book doesn't have a SimpleDotComGame file, doesn't have you write one in the chapter, and isn't in the chap 5 download files.
13 years ago
Hello, I'm having trouble with chapter 5 of Head First Java, the SimpleDotComGame.

I tried searching but couldn't find anything so if theres another thread about the same problem and solution, I'm sorry for not finding it.

Well I get up to page 113 where we go to play the game after copying and pasting the ready back GameHelper class. So I try to compile the code and I see something weird: in the CMD window, it says java SimpleDotComGame...

No where in the chapter did we make a SimpleDotComGame file. I look in the errata and downloaded the code for Chap 5 and didn't see SimpleDotComGame file anywhere.

So I try javac SimpleDotComGame and get a file not found error so I Figure its a typo. Then I try javac SimpleDotCom:

...and it compiles fine.

Then I go to run it


So I figured I typed something in wrong and go download the files from the books site, and I get the same errors.... Thanks for any help~
13 years ago