We have been creating a Vehicle System in April25_VehicleSystem.java. Now we want to finish the system by creating a functional menu for the system like the following.
Please select one of the options below: 1. Add a new vehicle into the system. 2. Find vehicles by its maker. 3. Get all fuel-efficient vehicles. 4. Exit Enter your selection:
The system should continuously provide the user with the above selection. This means you need to create a forever loop.
1. Add a new vehicle into the system
When users select number “1”, your program should ask the user for all vehicles attributes to generate a new Vehicle. We have done a lot of exercises in the past several weeks on how to create a new Vehicle object. Look at April25_VehicleSystem.main method, you should be able to find an example on how to do this. Once a new vehicle is created, add to April25_VehicleSystem by calling addVehicle(Vehicle) method. If implemented correctly, it will do the following
Please select one of the options below: 1. Add a new vehicle into the system. 2. Find vehicles by its maker. 3. Get all fuel-efficient vehicles. 4. Exit Enter your selection: 1 Enter a new vehicle Maker name? BMW Enter a new vehicle Model name? X3 Enter a new vehicle passenger capacity? 5 Enter a new vehicle fuel Cap? 17 Enter a new vehicle mpg? 29 The following vehicle has been added to the system BMW, X3, it can fit 5 passengers, 493 miles
2. Find vehicles by its maker
When a user select number “2”, your program should find all vehicles inside the system according to its maker. The program needs to ask the user which carmaker that he/she wishes to find. To accomplish this, your program needs to call the existing April25_VehicleSystem.printAllModels(maker) method. If implemented correctly, it will do the following
Please select one of the options below: 1. Add a new vehicle into the system. 2. Find vehicles by its maker. 3. Get all fuel-efficient vehicles. 4. Exit Enter your selection: 2 Enter a vehicle maker: Honda Honda, Accord, it can fit 5 passengers, 450 miles Honda, Civic, it can fit 5 passengers, 455 miles
3. Get all fuel-efficient vehicles
When users select number “3”, your program should find all vehicles that are fuel-efficient. To accomplish this, your program needs to call the existing April25_VehicleSystem.printAllFuelEfficientVehicles() method. If implemented correctly, it will do the following
Please select one of the options below: 1. Add a new vehicle into the system. 2. Find vehicles by its maker. 3. Get all fuel-efficient vehicles. 4. Exit Enter your selection: 3 All fuel-efficient vehicles Honda, Accord, it can fit 5 passengers, 450 miles Honda, Civic, it can fit 5 passengers, 455 miles
4. Exit
When users select number “4”, your program should break from the forever loop.