I would do it differently. I would save the start odometer value in the database, and I would save how many KM (or miles) were completed:
START | TRIP | FUEL
60000 | 5000 | 5.0
65000 | 15000 | 15.0
Then you will have this as your Java class:
public class FuelLog {
private double start;
private double trip;
private double fuel;
}
, , . , , "" + , / .
, .
, , , , , " " . :
START | TRIP | FUEL | INDEX
60000 | 5000 | 5.0 | 1
65000 | 15000 | 15.0 | 2
Java, FuelLog, Hibernate:
public class Car {
private List<FuelLog> fuelLog;
public double getFuelEconomy(FuelLog log){}
}
Car , . fuelEconomy FuelLog.