Question: Create a class Car name, model, color (String, int, String) Overloaded constructor toString Method Create second class Vehicle type, horse_power, array of Car class type,
Create a class Car
- name, model, color (String, int, String)
- Overloaded constructor
- toString Method
Create second class Vehicle
- type, horse_power, array of Car class type, count (String, int, Car, int)
- Overloaded constructor (set car array size to 5)
- AddCar(name, model, color) method
- Add RemoveCar() method in previous lab program.
- Add searchCar() method in Vehicle class that will return true if the car is available in the car array otherwise false. The searchCar() takes one String parameter car_name
Create third class Main
- Create object of Vehicle class
- Call AddCar method and add 5 cars by giving name, model, and color value
- Print all the vehicle details
- Remove a car by calling removeCar() method.
- Display Vehicle after deleting a car
- Search a car. If the car is available, display all the details of that car.
Sub Task 1.1:
- In the previous program add one more static integer variable in Vehicle class called NUMBER_OF_CAR = 0.
- In the constructor of Vehicle, class increment NUMBER_OF_CAR.
- Add a static method in Vehicle class called NumberOfCars() that will return NUMBER_OF_CAR value.
- In the AddCar method of Vehicle class check whether the array of Car object array is full or not. If it is full, display a message called 'Class is full', otherwise add the Car to the array
- Display the all the added car details by calling toString method
- Using Java
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
