• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

oop-2 naturallanguagemultiply

 
Sheriff
Posts: 4012
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For this assignment are we required to check whether the user gives a funny number like two-twenty or fifty-fifty?
Thanks,
Pauline
 
tumbleweed
Posts: 5089
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).]
 
whippersnapper
Posts: 1843
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Pauline,
You can do it anyhow. (It only takes a couple of lines of code.)
 
Pauline McNamara
Sheriff
Posts: 4012
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 1843
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 1843
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 4012
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I prefer to find any way to test for range besides exception handling. It makes your code much more readable.
 
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does the instructors solution return anything for two-twenty and fifty-fifty-two?
 
Marilyn de Queiroz
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4012
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
You showed up just in time for the waffles! And this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic