Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

constructors with exceptions

807600Jun 4 2007 — edited Jun 5 2007
i have to create a class TornadoException with two constructors, one default, if the exception is thrown with the default constructor the method getMessage should return "Tornado: Take cover!"
the other constructor has a single parameter int m, if the exception is thrown with this constructor the getMessage should return "Tornado: m miles away!"

I also have to write a driver class that creates two objects, one with each constructor, and use a random number to choose which object to throw. and write a catch block that catches the exception and prints the string returned by the getMessage method.

this is a hw assignment and im not sure hw to approach it, it doesnt seem to be defined well, what am i supposed to put in the try block? any help would be great.

Thanks,
Peter
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 3 2007
Added on Jun 4 2007
8 comments
737 views