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?