You are on page 1of 3

WEEK#10 LAB

Exception I

CSC113
EVALUATION QUESTION
• checkPlate(int index, char ch): checks if the car’s
plate number includes the character (ch) at the
received index.

• Write a test class that performs the following:


1. Create a Vehicle list (name it vList) that can handle up to
three elements.
2. Read two cars information, add them to vList, and display
each car in vList
• Your program should handle the following
exceptions:
1. InputMismatchException: if the user enters an invalid value
(character) for speed attribute; print an appropriate message
and prompt the user to enter a new speed.
2. The constructor of class Vehicle should make sure that the
entered speed is not a negative number; if so it should throw
NegativeNumberException (a user defined exception) that
should be handled in the calling environment by:
3 • Printing its message.
• Allowing the user to re-enter a new age value until a valid one is received

You might also like