1. Engineering
  2. Computer Science
  3. this assignment is about aggregation and class collaboration you will...

Question: this assignment is about aggregation and class collaboration you will...

Question details

This assignment is about aggregation and class collaboration.

You will create several Classes that will be part of an overall class named InstrumentDisplay. The classes are FuelGage, Odometer, MilesSinceLastGas, and CruisingRange.

The FuelGage should assume a 15 gallon tank of gasoline and an average consumption of 1 gallon every 28 miles. It should increment in 1 gallon steps when you "add gas to the tank". It should decrement by 1 every 28 miles. It should display its current value.

You should also have a display that shows how many miles traveled since you last added gasoline, MilesSinceLastGas, and a display for the estimated number of miles until you run out of gasoline, the CruisingRange.

The Odometer should keep track of total mileage from 0 to 999,999. After that it turns over back to 0. Make sure your code allows for this rollover.

The overall class is to be named InstrumentDisplay. You may create the various outputs using System.out or JOptionPane. Make sure that account for both filling and emptying the tank. While your odometer will display in 1 mile increments, you should keep track of mileage internally in one tenth of a mile increments for purposes of computing gasoline remaining in the FuelGage and miles in the CruisingRange

Please make sure you comment your code thoroughly.

The code should be nicely formatted and should use proper variables.

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution