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:
- Default constructor (which sets all variables to their respective default values)
- Constructor which accepts all the variables
- 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:
- Public void addProductionYear(int year); *
- Public Boolean isSameManufacturer(Vehicle v); **
- 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
Get step-by-step solutions from verified subject matter experts
