예제 #1
0
파일: Route.java 프로젝트: treacher/KPSMail
  /**
   * gets a transport firm with the given company name
   *
   * @param companyName
   * @return
   */
  public TransportFirm getTransportFirm(String companyName) {

    for (TransportFirm t : firms) {
      if (t.getCompany().equals(companyName)) {
        return t;
      }
    }

    // Could not find a transport firm with the given name.
    return null;
  }
예제 #2
0
파일: Route.java 프로젝트: treacher/KPSMail
  /**
   * gets a valid transport firm that supports a package
   *
   * @precondition requires firms to be sorted by cost
   * @param md
   * @return
   */
  public TransportFirm getTransportFirm(MailDelivery md) {

    Priority p = md.priority;
    double weight = md.weight;
    double volume = md.volume;

    for (TransportFirm t : firms) {

      if (weight <= t.getMaxWeight()
          && volume <= t.getMaxVolume()
          && !(p.isAir() == !t.getType().isAir())) return t;
    }

    return null;
  }