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.