|
SINCE THIS IS YOUR FINAL EXAM, I thought
it appropriate to condition you to the possibility of an imminent vacation.
In this programming assignment,
the goal is to have your vehicle arrive at its destination with
no more fuel than necessary. (0 liters is expected)
The program opens with a vehicle on Highway
401 at Exit
(Avenue) 0, heading East, with some fuel (in liters) in the tank. The amount
of fuel the vehicle has is displayed as its label. The driver file is
written so that there is a random possibility that there is
just enough fuel for the trip without the need to pull into the gas station.
Since gas stations
along the 401 are quite far apart, the decision about whether to
take on fuel is critical. In this exam, you are restricted to two choices.
- If you arrive at the Exit (Avenue) of the only gas station en route
and it is determined that insufficient fuel reserves are in the tank,
you are
to pull into the station and take on only as much fuel as is required
to get to your destination (ending with 0 liters), or,
- If it is determined that the vehicle's tank contains enough fuel
to reach the intended destination, no refueling will be made.
Examine the following Sample Runs.
RUN |
COMMENTS |
|
Vehicle has just enough fuel to reach the destination (no refueling
required) |
|
Vehicle has insufficient fuel to reach its destination and must acquire
just enough to arrive on an empty tank. Notice how the pump was depleted
by 4 liters after the vehicle took just as much as it needed to reach its
destination. |
|
Program must be prepared to exit for fuel even a Exit (avenue) 0. |
TASK. Using the driver, RoadTrip.java,
without modification, develop the Vehicle and GasStation classes
as defined by the following UML diagrams (see also the Javadoc
Documentation),
that will permit you to arrive at your destination with 0 liters of fuel
remaining in your tank. Submit the fully documented source files
Vehicle.java and GasStation.java to handin with the Subject: Final
Exam.

|