Creating Your Own Exception Class
For one point of extra credit, you are to create your own Exception class, named DuplicateIDexception
. The exception is to be thrown whenever a Student is constructed who does not have a unique ID. When the exception is caught, a message to the user with the name of the student and the ID is displayed as follows:
Joe Smith's ID number, 30, is not unique and can not be assigned.
To help you accomplish this task, you are to store all IDs into a TreeSet. Click here for the API of a TreeSet.
Your Exception class constructor should take at least two arguments:
- a message, and
- the ID number that is not unique.