Only for Java programmer or computer programming expert.

profilePerfectqsdf
Odometer.java

/** *Description: This program will demonstrate the classes by creating instances of each. Stimulate filling the car up with fuel, then run aloop that increament the odometer until the car runs out of fuel. *Class: Fall - COSC 1437.81002 *Assignment7: Odometer class code *Date: 10/23/2018 *@author Deepak Bhusal *@version 0.0.0 */ /** * This class used to calculate the value of odometer */ public class Odometer { private int mileage; private int setPoint; // Miles since the fuel was last decremented private FuelGauge fuelGauge; // Constant for the maximum mileage private final int MAX_MILEAGE = 999999; // Constant for the miles-per-gallon private final int MPG = 24; /** * Constructor Odometer creates two parameters m for mileage and fg for FuelGauge *and store the value in the respective parameters. * @param m * Initial mileage. * @param fg * A reference to a FuelGauge object. */ public Odometer(int m, FuelGauge fg) { fuelGauge = fg; mileage = m; } /** * getMileage method * * @returns The mileage. */ public int getMileage() { return mileage; } /** * The incrementMileage method increments the mileage field. If mileage * exceeds the maximum amount, it "wrap around" mileage. */ public void incrementMileage() { mileage += 1; // If mileage is over the max, "wrap around" mileage = mileage % (MAX_MILEAGE+1); setPoint += 1; // Keep track of how many miles it's been since we decremented the fuel while (setPoint >= MPG) { fuelGauge.decrementGallons(); setPoint = setPoint - MPG; } } }