Hi, I'm back again. Sorry to trouble you.
I'm still have difficulties with outputting the error "Only Vehicle object Records can be stored".
I think maybe I'm being a little dumb and I apologise if this is the case. I don't normally have any difficulty producing errors.
My program is working fine BUT I don't want it to.....
I have used the type casting of an object successfully.
My code in my test cast is as follows:
my store method in the VehicleDB class is as follows:
//method to store the vehicle registration
public void store (VehicleRecord vr) throws InvalidRecord
Which is what we are told we are NOT to change; we have to use this.
And the result output to screen I get is:
VehicleRecord details:
======================
Registration Registration: Car Car Car
Number: Date: Make: Model: Colour:
1234567 0185 Maureen Charlton UK
Validating Registration Date: 0185
The length of the date input by user is: 4
Length of date successfully validated i.e. four digits or characters
VALIDATING YEAR
newYear is: 1985
Finished validating Registration
VALIDATING MONTH
newDate is: 01
Registration Month successfully validated
VALIDATING REGISTRATION NUMBER: 1234567
The length of the reg input by user is: 7
Length of registration: VALID i.e is 7 characters
VALIDATING FORMAT OF REGISTRATION:
First Character is NOT a letter
Invalid Registration Number Format
Working like a dream!!! Which is NOT what I wish to have.
I would like an Exception to be caught but it isn't happening.
I have no errors. Not something I have a problem with normally!
Am I missing something BIG time here?