Develop a Java program as specified below. Your program has two classes.
The Vehicle class
- In this class define the following properties
for a Vehicle. All properties should be private.
- tag number, like "ABC 1234"
- fuel capacity in gallons, like 30
- range in miles, like 600
- maximum number of passengers, like 7
- Add a constructor to the Vehicle class
that is invoked when a Vehicle is instantiated as, for instance,
new Vehicle("ABC 1234", 20, 350, 6)
- Add an instance method named getTag
to the class which returns the vehicle's tag number.
- Add an instance method named getCapacity
to the class which returns the maximum number of passengers for the vehicle
- Add an instance method named getFuelEfficiency
to the class which returns the miles per gallon for
the vehicle, like 23.5
The TestVehicle class
This class has one method, the main method. In this method, do
the following:
- Prompt the user for the tag number of his/her vehicle.
Save the user response.
- Prompt the user for the fuel capacity
of his vehicle. Save the user response.
- Prompt the user for the range of her vehicle.
Save the user response.
- Prompt the user for the passenger capacity of her vehicle.
Save the user response.
- Instantiate a Vehicle object
using the information supplied by the user in the previous steps.
- Invoke the getFuelEfficiency method
to obtain the fuel efficiency of the Vehicle object created in the previous
step. Store it.
- Display the tag number, passenger capacity, and the fuel efficiency
of the vehicle on the screen and categorize the vehicle as being either
"Very Efficient" (efficiency >= 35), or as being "Moderately
Efficient" (efficiency >= 20 and < 35), or "Gas Hog" (efficiency
< 20)
- Repeat steps 1 through 6 till the user types in QUIT when prompted for the tag number
Question: Assume that all the vehicles belong to the same group, say the UNCW Motor Pool. What changes would you make to your code to associate this information with each vehicle?