Kevin O'Sullivan wrote:Could you catch it with a try/catch in your tester class? and if you can how would you do it?
At which point you realise that you should have used a more informative error message for your exception. As a general rule of thumb, you shouldn't catch unchecked exceptions, but this looks like a situation where that is a reasonable thing to do. There are much more elegant ways to create such Cars; the
nextInt() method is overridden so as only to return values in a pre‑defined range, so you can avoid the exception altogether. I shall let you work out how the
KeyboardInputs class works.