Exemple #1
0
  public double lookupDistBand(double dist) {

    final double MILE = 1609.344;
    double miles = dist / MILE;

    if (dist_bands.size() == 0) {
      return 0;
    }
    for (DistanceBand d_band : dist_bands) {

      if (d_band.getDist1() != d_band.getDist2()) {
        if (miles <= d_band.getDist2() && miles > d_band.getDist1()) {
          if (d_band.getType().equals("flat rate")) {
            return d_band
                .getFare(); // just return the fare for now. Don't check the distance band type
          } else {
            return getFlatRate((int) d_band.getDist1())
                + ((int) (miles - d_band.getDist1()) + 1) * d_band.getFare();
          }
        }
      }
    }
    return -1;
  }
Exemple #2
0
  public double getFlatRate(int uptomileage) {

    for (DistanceBand d_band : dist_bands) {
      if (d_band.getType().equals("flat rate")) {
        if (d_band.getDist1() == d_band.getDist2()) {
          if (uptomileage == d_band.getDist1()) {
            return d_band.getFare();
          }
        }
      }
    }
    return 0;
  }