Question: create an exception handling JAVA assignment. Create a class Vehicle with below attributes: int - number String - name double - price Create a constructor

create an exception handling JAVA assignment.

 create an exception handling JAVA assignment. Create a class Vehicle with

Create a class Vehicle with below attributes: int - number String - name double - price Create a constructor which takes all parameters in the above sequence. The constructor should set the value of attributes to parameter values inside the constructor. Create getters and setters for all the above attributes Create a class VehicleExistsException extending the Exception class. Override the getMessage method which should return the number value for which object exists. Create a class Customer with below attributes: int - id String - name String dob double salary String - email int - age ArrayList vehicleDetailsList Create a method addVehicle which takes fields of Vehicle in the order of number, name, price and adds the same to Vehicle list if there is no object present in the list with same value of number. 1 The above method should throw the exception. Handle the exception in the main method. Return -1 if there is an object with the same value of number else return the total count of Vehicle objects in the list. Create a class CustomerDemo with a main method. Create an object of Customer and call the above method from the main method

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!