jQuery in Action, 2nd edition
The moose likes Cattle Drive and the fly likes oop-2 naturallanguagemultiply Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » This Site » Cattle Drive
Reply Bookmark "oop-2 naturallanguagemultiply" Watch "oop-2 naturallanguagemultiply" New topic
Author

oop-2 naturallanguagemultiply

Pauline McNamara
Sheriff

Joined: Jan 19, 2001
Posts: 4011
For this assignment are we required to check whether the user gives a funny number like two-twenty or fifty-fifty?
Thanks,
Pauline
Johannes de Jong
tumbleweed
Bartender

Joined: Jan 27, 2001
Posts: 5089
Nope.
By the way when I run the instructors solution with two-twenty fifty-fifty as input the result is 2200
[This message has been edited by Johannes de Jong (edited August 23, 2001).]
Michael Matola
whippersnapper
Ranch Hand

Joined: Mar 25, 2001
Posts: 1721
Pauline,
You can do it anyhow. (It only takes a couple of lines of code.)
Pauline McNamara
Sheriff

Joined: Jan 19, 2001
Posts: 4011
Thanks. I'd gotten this to work with those funny numbers too, but I think I'll have a try at preventing it.
In that case, is this something that should be treated like an exception?
Pauline
Michael Matola
whippersnapper
Ranch Hand

Joined: Mar 25, 2001
Posts: 1721
Originally posted by Pauline McNamara:
I'd gotten this to work with those funny numbers too, but I think I'll have a try at preventing it.

My first version of preventing "seven-eleven" and suchlike was pretty ugly. But the revised version I submitted for nitpicking turned out to be quite clean and readable.

In that case, is this something that should be treated like an exception?

Tough call. Part of this assignment is about learning to use exceptions. I did the checking for funny numbers and threw an exception. But my passing version of the assignment ended up using exceptions in a manner that was a bit different from the instructor's solution. I'm still debating the plusses and minusses of the approach I took.
Regardless, I thought this assignment was a lot of fun. That's why I went ahead and did the extra validation bit.
Actually, I'd be interested trading code with anybody else who's passed this assignment with a solution that prevents the funny numbers. I'd like to see what other versions got the nitpicker's OK.
Michael Matola
whippersnapper
Ranch Hand

Joined: Mar 25, 2001
Posts: 1721
Originally posted by Michael Matola:
My first version of preventing "seven-eleven" and suchlike was pretty ugly. But the revised version I submitted for nitpicking turned out to be quite clean and readable.

In my first version I was testing for 5 different special cases to prevent. The revised version only had 3 special cases to prevent.
Pauline McNamara
Sheriff

Joined: Jan 19, 2001
Posts: 4011
now I think I will definitely have to play with this.
Actually, I'd be interested trading code with anybody else who's passed this assignment with a solution that prevents the funny numbers. I'd like to see what other versions got the nitpicker's OK.

Are you patient? I have a feeling it will take few rounds before all the nits are cleaned from my attempts, but it'd be fun to see how you solved it too.
Cheers,
Pauline
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9033
    
  10
I prefer to find any way to test for range besides exception handling. It makes your code much more readable.


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Lance Finney
Ranch Hand

Joined: Apr 26, 2001
Posts: 133
Does the instructors solution return anything for two-twenty and fifty-fifty-two?
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9033
    
  10
The important thing is that all of the requirements for the assignment are met. There is no requirement to disallow bogus data - just a requirement about reporting stuff that is not understood.
Pauline McNamara
Sheriff

Joined: Jan 19, 2001
Posts: 4011
Originally posted by Marilyn deQueiroz:
There is no requirement to disallow bogus data - just a requirement about reporting stuff that is not understood.

In that case I'll submit without that validation check - it's pretty clear that Marilyn doesn't need yet more work.
It was fun to play with anyhow.
Pauline
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: oop-2 naturallanguagemultiply
 
Similar Threads
How many objects will create
Find the bands
Pakistan v/s Australia
Who is going to buy Sun microsystems?
display first few records