0

I would like to reproduce the car fuel tank which will show the current percentage content and at the same time the filling will decrease in proportion to the amount of fuel in the tank. Possibly change the background colors if the fuel drops to a certain amount. Any ideas? I'm just learning and I'm starting to give up. I've been fighting this since yesterday.

Necessary class fields

public class Car extends Vehicle {

    private double fuel;
    private final double fuelCapacity = 54;
    private double fuelUsage = 7.4;
    private double carMileage = 0.000;
    private double distancePerSec;
    private double fuelPerSec;
    private final int carMaxSpeed = 215;
    private double currentCarSpeed;

    public void fuelUsagePerSecond() throws InterruptedException {
        if (getStatus() == MOVING && fuel > 0) {
            fuelUsage = fuelUsage + (getCurrentCarSpeed() / 25);
            fuelPerSec = fuelUsage / 3600;
            fuel = fuel - fuelPerSec;
        }
        else if (fuel <= 0){
            Car.super.stop();
            fuel = 0;
        }
    }
}

How to do it using java fx?

c0der
  • 18,467
  • 6
  • 33
  • 65
  • https://docs.oracle.com/javase/8/javafx/api/javafx/beans/Observable.html This let's the variable be observed, read this please. This is what can tie your variable value to javaFX properties – Willy Wonka Feb 28 '19 at 11:20
  • 1
    Can you use a `DialPlot`, like [this](https://stackoverflow.com/q/16163964/230513)? – trashgod Feb 28 '19 at 14:16

0 Answers0