Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Cattle Drive and the fly likes void Say4b( String whilePullingOutHair ) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » This Site » Cattle Drive
Bookmark "void Say4b( String whilePullingOutHair )" Watch "void Say4b( String whilePullingOutHair )" New topic
Author

void Say4b( String whilePullingOutHair )

Matthew Phillips
Ranch Hand

Joined: Mar 09, 2001
Posts: 2676
My code looks something like this

The number that userInput is being tested against gets progressively smaller, as does userInput. The nitpick I received is that there is a lot of similar code, which leads me to believe that this could be simplified. This code was used to replace a loop, so a loop is out. I have thought about a switch statement, but it seems that I would have to have just as many if statements to set the integral expression for the switch. Would someone please give me a hint? Thanks.
Matthew Phillips


Matthew Phillips
Joel Cochran
Ranch Hand

Joined: Mar 23, 2001
Posts: 301
hmmmmm... what if the number test was part of someMethod...
------------------
I'm a soldier in the NetScape Wars...
Joel


Wait a minute, I'm trying to think of something clever to say...<p>Joel
Johannes de Jong
tumbleweed
Bartender

Joined: Jan 27, 2001
Posts: 5089
Have a look at this posting http://www.javaranch.com/ubb/Forum19/HTML/000531.html
Good luck
Matthew Phillips
Ranch Hand

Joined: Mar 09, 2001
Posts: 2676
Thanks for the assistance. It's getting to the point where I can't see the little things with Say. I have been looking at it for entirely too long. Hopefully these hints will get me over the hump.
Matthew Phillips
Johannes de Jong
tumbleweed
Bartender

Joined: Jan 27, 2001
Posts: 5089
My wife always says, walk away from it, wise little creature
Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1194
Yeah, but she forgot about the ending which goes like this:
...and when it's not looking, kick it in the rear and then run!
Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1194
Seriously Matthew, on some of my previous nightmares- uh I mean assignments, I found that scratching everything and starting fresh opened up a whole new vista, where I could get a glimpse of where I wanted to be!
Johannes de Jong
tumbleweed
Bartender

Joined: Jan 27, 2001
Posts: 5089
Actually she never did
Matthew Phillips
Ranch Hand

Joined: Mar 09, 2001
Posts: 2676
The thing that has kept me trudging along with Say has been the knowledge that I will learn something in the end and doing a little working ahead on the assignments. When I implemented the suggestions from the replies I finally saw why this method is more simple than the loop I had previously. Now that I have seen that my perspective of Say has been refreshed, although I still want to kick it in the butt while it's not looking.
Matthew Phillips
Johannes de Jong
tumbleweed
Bartender

Joined: Jan 27, 2001
Posts: 5089
Wait till you get the instructor's solution and it kicks back
 
wood burning stoves
 
subject: void Say4b( String whilePullingOutHair )
 
Similar Threads
multi-inheritance
Question on searching ArrayLists
calling a method w/out an object
Strange bug in a class I wrote (not sure how to explain in title)
variables may not be initialized