Class Calculator

java.lang.Object
control.Calculator

public class Calculator extends Object
The Calculator class provides methods for calculating shipping costs based on packet dimensions and weight.

Includes a method for calculating shipping costs using the loaded shipping rules and converting the packet dimensions to metric units if needed using the current setting from SettingsManager and converting method provided by MeasurementSystem. Also uses the ShippingRuleLoader to load the shipping rules from an external JSON file.

See Also:
  • Constructor Details

    • Calculator

      public Calculator()
  • Method Details

    • calcShippingCosts

      public static double calcShippingCosts(Packet pack) throws ShippingRuleException
      Calculates the shipping costs based on the dimensions and weight of the given packet. Uses the shipping rules loaded from an external JSON file.
      Parameters:
      pack - the packet for which the shipping costs are to be calculated
      Returns:
      the calculated shipping costs
      Throws:
      ShippingRuleException - if the shipping rules cannot be loaded