Exemple #1
0
  private float totalDistance(List<Fuel> records) {
    float distance = 0;

    for (Fuel record : records) {
      distance += record.getDistance();
    }
    return distance;
  }
Exemple #2
0
  private float totalFuel(List<Fuel> records) {
    float liters = 0;

    for (Fuel record : records) {
      liters += record.getLiters();
    }
    return liters;
  }
Exemple #3
0
  private Chart buildRefuelChart(List<Fuel> records) {
    Chart refuelList = new Chart();
    DateValueChart chartRow;
    for (Fuel record : records) {
      chartRow = new DateValueChart();
      chartRow.setDate(record.getDate());
      chartRow.setValue(record.getLiters());
      refuelList.add(chartRow);
    }

    return refuelList;
  }
Exemple #4
0
  private Chart buildDistanceChart(List<Fuel> records) {
    Chart distanceList = new Chart();
    DateValueChart chartRow;
    for (Fuel record : records) {
      chartRow = new DateValueChart();
      chartRow.setDate(record.getDate());
      chartRow.setValue(record.getDistance());
      distanceList.add(chartRow);
    }

    return distanceList;
  }
Exemple #5
0
  private Chart buildConsumptionChart(List<Fuel> records) {

    Chart consumptionList = new Chart();

    int id = 0;
    for (Fuel record : records) {
      ConsumptionChart consumptionChart = new ConsumptionChart();
      consumptionChart.setInterval(id++);
      consumptionChart.setValue(consumption(record.getLiters(), record.getDistance()));
      consumptionList.add(consumptionChart);
    }
    return consumptionList;
  }
Exemple #6
0
  private List<Fuel> buildFuelList(List<Fuel> records) {
    List<Fuel> fuelList = new ArrayList<Fuel>();
    int currentRecord = records.size() - 1;
    float liters = 0;
    float distance = 0;
    boolean city = false;
    boolean mixed = false;
    Date date = new Date();

    while (currentRecord >= 0) {
      Fuel fuel = new Fuel();
      liters = records.get(currentRecord).getLiters();
      distance = records.get(currentRecord).getDistance();
      city = records.get(currentRecord).isCity();
      mixed = records.get(currentRecord).isMixed();
      date = records.get(currentRecord).getDate();
      while (records.get(currentRecord).getDistance() == 0) {
        currentRecord--;
        liters += records.get(currentRecord).getLiters();
        distance = records.get(currentRecord).getDistance();
      }
      currentRecord--;
      fuel.setLiters(liters);
      fuel.setDistance(distance);
      fuel.setCity(city);
      fuel.setMixed(mixed);
      fuel.setDate(date);
      fuelList.add(fuel);
    }
    return fuelList;
  }