Only for java Programmer or Computer Science Expert Not Essay Writer Please

profileSaMsRa@1
Odometer.java

/** * Description: The class odometer is used simulate car odometer. It contains * variable mileage which indicates the miles traveled so far * the MAX_MILEAGE value hold the maximum miles that odometer can read * MPG hold the miles traveled per gallon. This class uses FuelGauge to make * changes when the car * Class: Fall - COSC 1437.81003 * Assignment7: Odometer class code * Date: 10/23/2018 */ /** * The class odometer is used simulate car odometer. It contains * variable mileage which indicate the miles traveled so far * the MAX_MILEAGE value hold the maximum miles that odometer can read * MPG hold the miles traveled per gallon. This class uses FuelGauge to make * changes when the car moves another 24 miles * @author Bhaskar Bharati * @version 0.6.12 */ public class Odometer { //Declare class variables private int mileage; //current reading of odometer final int MPG = 24; //miles travelled using one gallon final int MAX_MILEAGE = 999999; //maximum odometer reading FuelGauge fuelG; //reference fueldGauge object int setPoint; /** * This is a class constructor that initializes the value of Odometer and * fuelgauge * * @param mileage The value of mileage is stored in the mileage parameter. */ public Odometer(int mileage, FuelGauge fg) { if (mileage >= 0) { this.mileage = mileage; setPoint = mileage; } else { mileage = 0; setPoint = 0; System.err.println("mileage cannot be less than 0"); } fuelG = fg; } /** * getmileage method returns the value of odometer * * @return The current reading of odometer */ public double getMileage() { return mileage; } /** * incrementMileage method increases the mileage reading by 1 pointer * * @param fuel The value of fuel is stored in fg parameter. */ public void incrementMileage() { if (mileage <= MAX_MILEAGE) { mileage += 1; } else { mileage = 0; } if (mileage % MPG == 0) { fuelG.decrementGallons(); } } }