Question: Create a UsedCarException class that extends Exception; its constructor receives a value for a vehicle identification number (VIN) that is passed to the parent constructor
Create a UsedCarException class that extends Exception; its constructor receives a value for a vehicle identification number (VIN) that is passed to the parent constructor so it can be used in a getMessage() call. Save the class as UsedCarException.java. Create a UsedCar class with fields for VIN, make, year, mileage, and price. The UsedCar constructor throws a UsedCarException when the VIN is not four digits; when the make is not Ford, Honda, Toyota, Chrysler, or Other; when the year is not between 1990 and 2014 inclusive; or either the mileage or price is negative. Save the class as UsedCar.java. Write an application that establishes an array of at least seven UsedCar objects and handles any Exceptions. Display a list of only the UsedCar objects that were constructed successfully. Save the file as ThrowUsedCarExceptions.java.
Step by Step Solution
3.48 Rating (161 Votes )
There are 3 Steps involved in it
ThrowUsedCarException public class ThrowUsedCarException public static void mainString args UsedCar cars new UsedCar7 String vins 1234 2345 234Q 12345 ... View full answer
Get step-by-step solutions from verified subject matter experts
