Perhaps the requirements should be clarified a bit on this one, as far as the specifics for throwing the Exception.
The way I initially threw/caught the exception worked great - it met all the requirements mentioned in the assignment specs, including outputting the exact text not recognized. I just didn't explicitly
throw the exception from within a conditional in the toInt method. Instead, I declared that toInt throws Exception (as required by signature specs), and simply called it from within a try/catch block. In the catch portion, I built the error message, specifying the unrecognized
string culprit.
To me, this was fine, but I still got the nit "Where is the exception you are creating (with text) and throwing?" mentioned at the end of my toInt method. I was relying on the fact that the exception was thrown whenever toInt was passed an unrecognized string, without having to use conditionals to determine whether or not a string was in the map.
I guess the purpose of this message is to alert students to the fact that you can save yourself a nit by not doing it the way I did at first. Or perhaps the specs for the assignment should state that the exception MUST be created and explicitly thrown in the toInt method.
------------------
- Ryan Burgdorfer
- Java Acolyte