Look here, where you will find you shouldn't have anything in the main() method. Well, maybe oe statement, but that is it.
wayne brandon wrote:. . . isnt it sloppy design to just have that loop in the main?
That is what I thought you meant all along, a method in your input class to test for yes/no.
shouldnt it be self contained in the input utility.
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.
wayne brandon wrote:. . . is it ok to just call another method in the same class or another class for example . . .
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.
Pedro Esgueira wrote:. . . My question is: those references were defined in main, . . .
I think BG has explained that nicely already.
. . . how can the answer to this exercise be "roar roar!!!"? . . .
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.
Knute Snortum wrote:. . . I don't think this is "cheating" at all, but is probably the way the authors intended us to do it.
Look in the old Sun style guide, where you find they don't like return true; or return false;
wayne brandon wrote:. . . How do i use the return in these lines?. . .
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().
Pedro Esgueira wrote:. . . the variables roar1 and roar2 are defined inside the main() block of code . . .
I probably don't have that book, so I can't answer without seeing the whole question.
. . . I will not print the enire code . . .