package seatrading.main;

/**
 * @author Daniel "3ICE" Berezvai
 */
public class Container {

  public static final double MAX_WEIGHT = 32;
  public static final double CAPACITY = MAX_WEIGHT - 2;
  public Goods goods;
  private double weight;

  /**
   * Empty containers weigh 2 tons. If you try to squeeze more than
   * {@value #CAPACITY} tons in the container, the entire universe will collapse
   * in on itself.
   *
   * @param goods the contents
   * @throws seatrading.main.Container.CapacityOverflow
   */
  public Container(Goods goods) throws CapacityOverflow {
    weight = goods.getWeight() + 2;
    if (weight > MAX_WEIGHT + 2) {
      throw new CapacityOverflow();
    }
    this.goods = goods;
//    System.out.println("Container with " + goods.toString() + " created.");
  }

  /**
   * Hides weight behind a getter. Has no setter pair, intentionally.
   *
   * @return the weight
   */
  public double getWeight() {
    return weight;
  }

  private static class CapacityOverflow extends RuntimeException {
  }
}
