Campbell Ritchie

+ Follow
since Oct 13, 2005
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Campbell Ritchie

Welcome Well done finding the problem, but don't put your own work and java.exe in the same folder. It is usual to put java.exe in a subfolder of Program Files, and you add that to your system PATH environment variable.
43 seconds ago
Happy Birthday
23 minutes ago

wayne brandon wrote:. . . isnt it sloppy design to just have that loop in the main?

Look here, where you will find you shouldn't have anything in the main() method. Well, maybe oe statement, but that is it.

shouldnt it be self contained in the input utility.

That is what I thought you meant all along, a method in your input class to test for yes/no.
24 minutes ago

wayne brandon wrote:. . . is it ok to just call another method in the same class or another class for example . . .

As a general rule of thumb, it is usually OK to call another method of the current object (this) or another object, and yes, that is the usual way to move around a program.
Access is controlled from the called method, not the calling method. If you don't want a method called from a different class, give it private access.
33 minutes ago

Pedro Esgueira wrote:. . . My question is: those references were defined in main, . . .

No, they are defined in the roar() method. The fact that they have the same name as in main() doesn't mean they are the same variables, as BG has shown.

. . . how can the answer to this exercise be "roar roar!!!"? . . .

I think BG has explained that nicely already.
17 hours ago
Agree; it is all trade‑offs. Depends whether you like while (true) ... and multiple return xxx;
20 hours ago

Knute Snortum wrote:. . . I don't think this is "cheating" at all, but is probably the way the authors intended us to do it.

Agree; I think that is how Project Euler expect you to solve their problems. If you try it with heavy programming, you are likely to get slow execution and run out of time.
20 hours ago
So it does. I didn't see that
Remember the following link: OCA I book link, where you will find that error has already been reported. Maybe BG has a newer edition with the error correct; I don't know.
If you look here (remember that link), you will find that error is already known about.
Where does it say that substring() returns int? I can't see that; it says that indexOf() returns int, with −1 for “not found”.
That's a good idea, writing a utility class for keyboard input. You can use it again and again.

wayne brandon wrote:. . . How do i use the return in these lines?. . .

Look in the old Sun style guide, where you find they don't like return true; or return false;
You probably can't get that code to compile because you haven't covered all possible paths of execution and if I enter, “Don't know,”, you have no way of returning a result. What you do is to return your original expression:-That still won't cover the case where I write, “Don't know,”. I might be awkward enough to do that if I get my hands on your code, but you must allow for your users making simple mistaiks.Yes, the expression in lines 123‑126 is pretty awkward. Please search my posts for use of nextLine() and nextInt() because I think there are better ways to get the next line or the next int from your keyboard reader.
22 hours ago
Well done and welcome to the Ranch

Please add your name to (I think this is the correct link).
22 hours ago
Which guide? Please give the authors' names.

Pedro Esgueira wrote:. . .  the variables roar1 and roar2 are defined inside the main() block of code . . .

They are defined anew as method parameters for the roar() method. Watch what is passed, and you will see that the parameters in roar() receive object references passed from main().
Did you correctly predict what you would see printed? Was it, “roar roar!!!”?

. . . I will not print the enire code . . .

I probably don't have that book, so I can't answer without seeing the whole question.
22 hours ago
Are we playing poker? I was thinking more along the lines of a whist‑like game, but in either case adding A♠, A♡, A♢, and A♣ looks like a very good game strategy
23 hours ago