Example #1
0
  /**
   * @param year year in question
   * @param crop crop in question
   * @param metTons tons exported
   */
  public void setCropExport(int year, EnumFood crop, double metTons) {
    if (metTons >= 0) {
      // Divide it up amongst the units.
      //
      double perUnit = metTons / entities.size();
      double remainder = metTons % (entities.size() * perUnit);
      for (AgriculturalUnit unit : entities) {
        unit.setCropExport(year, crop, perUnit + remainder);
        remainder = 0;
      }

      cropExport[crop.ordinal()][year - START_YEAR] = metTons;
    } else {
      if (VERBOSE) {
        System.err.println("Invalid argument for AgriculturalUnit.setCropExport method");
      }
    }
  }