Class ShippingRule
java.lang.Object
data.ShippingRule
The ShippingRule class represents a rule for shipping packages based on their dimensions and weight.
Each rule specifies the maximum length, width, height, weight, and optionally girth of a package that can be shipped
according to this rule, as well as the cost for shipping such a package. It also provides a method to check if a
given
Packet
matches the rule.- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal double
getCost()
Retrieves the cost for shipping a package according to this rule.final Integer
Retrieves the maximum girth of a package that can be shipped according to this rule.final int
Retrieves the maximum height of a package that can be shipped according to this rule.final int
Retrieves the maximum length of a package that can be shipped according to this rule.final int
Retrieves the maximum weight of a package that can be shipped according to this rule.final int
Retrieves the maximum width of a package that can be shipped according to this rule.final String
getType()
Retrieves the type (name) of the package according to this shipping rule, e.g., "Small" or "Large".boolean
Checks if the given packet matches this shipping rule (i.e., fits within the dimensions and weight limits).
-
Constructor Details
-
ShippingRule
public ShippingRule()
-
-
Method Details
-
getType
Retrieves the type (name) of the package according to this shipping rule, e.g., "Small" or "Large".- Returns:
- the shipping rule type as a String
-
getCost
public final double getCost()Retrieves the cost for shipping a package according to this rule.- Returns:
- the shipping cost as a double
-
getMaxLength
public final int getMaxLength()Retrieves the maximum length of a package that can be shipped according to this rule.- Returns:
- the maximum length as an int
-
getMaxWidth
public final int getMaxWidth()Retrieves the maximum width of a package that can be shipped according to this rule.- Returns:
- the maximum width as an int
-
getMaxHeight
public final int getMaxHeight()Retrieves the maximum height of a package that can be shipped according to this rule.- Returns:
- the maximum height as an int
-
getMaxWeight
public final int getMaxWeight()Retrieves the maximum weight of a package that can be shipped according to this rule.- Returns:
- the maximum weight as an int
-
getMaxGirth
Retrieves the maximum girth of a package that can be shipped according to this rule.- Returns:
- the maximum girth as an int
-
matches
Checks if the given packet matches this shipping rule (i.e., fits within the dimensions and weight limits). Also respecting the optional girth limit if present.- Parameters:
pack
- the packet to check- Returns:
- true if the packet matches this rule, false otherwise
-