/** * Calculates the fuel economy (based on the user's preferences) since the previous fill-up. * * @return the fuel economy since the previous fill-up. */ public double calcEconomy() { if (m_partial) { return -1D; } if (m_economy == 0D) { FillUp previous = getPrevious(); if (previous == null) { return -1D; } double distance = calcDistance(); double fuel = getAmount(); while (previous != null) { if (previous.isPartial() == false) { break; } // partial; we need to keep iterating distance += previous.calcDistance(); fuel += previous.getAmount(); previous = previous.getPrevious(); } m_economy = m_calculator.calculateEconomy(distance, fuel); } return m_economy; }