Question: Please help me with this code. Thank you Implement the following Java class: Vehicle Class should contain next instance variables: Integer numberOfWheels ; Double engineCapacity

Please help me with this code. Thank you

Implement the following Java class: Vehicle

Class should contain next instance variables:

  • Integer numberOfWheels;
  • Double engineCapacity;
  • Boolean isElectric,
  • String manufacturer;
  • Array of integers productionYears;

Supply your class with:

  1. Default constructor (which sets all variables to their respective default values)
  2. Constructor which accepts all the variables
  3. All the appropriate getters and setters (you may skip comments for this methods. Also, make sure that for engineCapacity setter method you check first if the vehicle is electric. If it is not set engineCapacity to the new value, but if it is electric leave the value at 0 and display an error message);

Your class will implement following methods:

  1. Public void addProductionYear(int year); *
  2. Public Boolean isSameManufacturer(Vehicle v); **
  3. Public String toString(); ***

* - this method will expand array productionYears by 1 element and place argument int as the last subscript

** - this method will compare two objects by checking whether or not the manufacturer variables are the same

*** - this method will output all the information with a neat formatting

Write a driver program which will creates at least 2 object of this Class and tests all the methods

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!