Exemplo n.º 1
0
  /**
   * 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;
  }
Exemplo n.º 2
0
  /**
   * 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;
  }