package com.bookshop.solid.ocp;
import java.math.BigDecimal;
/** Standard post: flat rate, free above the threshold. */
public class StandardShipping implements ShippingRate {
/** Business rule: "free shipping over GBP 25" -- named so the rule is findable and searchable. */
static final BigDecimal FREE_SHIPPING_THRESHOLD = new BigDecimal("25.00");
static final BigDecimal STANDARD_COST = new BigDecimal("3.00");
@Override
public String name() {
return "standard";
}
@Override
public BigDecimal costFor(BigDecimal orderTotal) {
return orderTotal.compareTo(FREE_SHIPPING_THRESHOLD) >= 0
? BigDecimal.ZERO
: STANDARD_COST;
}
}