Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In the VehicleManager class, implement a main method that displays a menu - driven UI to the user. Before the menu is displayed, vehicles should
In the VehicleManager class, implement a main method that displays a menudriven UI to the user.
Before the menu is displayed, vehicles should be loaded from a file named vehiclestxt
The menu should present the following options:
View all vehicles in the system User enters and is shown a complete description of the vehicles in the system
View vehicles by type Car Truck, MotorcycleUser enters
Add a new vehicle User enters then the type of Vehicle Car Truck, then the subtype Electric or Fossil Fuel then all the properties in the order of the class constructor
Remove an existing vehicle User enters is presented with the list of vehicles, then enters the index of the vehicle to remove
Display fuel efficiency andor emissions for a vehicle User enters
Display fuel efficiency andor emissions for a vehicle type User enters then the type of Vehicle Car Truck,
Display fuel efficiency andor emissions for all vehicles User enters
Exit the program User enters Q
Implement methods to handle each menu option, utilizing the classes you have created Vehicle VehicleList, VehicleFileManager, etc
For the "Add a new vehicle" option, prompt the user to enter the necessary details and create an instance of the corresponding vehicle class. Add the new vehicle to the VehicleList.
For the "Remove an existing vehicle" option, display a list of all vehicles currently in the VehicleList and prompt the user to select a vehicle to remove.
For the "Calculate fuel efficiency" and "Calculate emissions" options, display a list of all vehicles currently in the VehicleList and prompt the user to select a vehicle. Then, calculate and display the fuel efficiency or emissions for the selected vehicle using the corresponding methods from the vehicle class.
For the "View all vehicles" option, display a list of all vehicles currently in the VehicleList, along with their types, fuel efficiency, and emissions.
For the "View vehicles by type" option, prompt the user to enter a vehicle type eg "Car", "Truck", "Motorcycle" and display a list of vehicles of that type, along with their fuel efficiency and emissions.
The main method should continuously display the menu options to the user until the "Exit" option is selected User enters Q Before exiting vehicles are saved into the file vehiclestxt
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started