package catering.order; import org.salespointframework.quantity.Quantity; import org.springframework.stereotype.Component; import java.util.HashMap; import java.util.Map; @Component public class CustomCart { private CustomOrder.OrderType orderType; private Map products; public CustomCart() { this.orderType = CustomOrder.OrderType.SOMETHING_ELSE; this.products = new HashMap<>(); } public CustomOrder.OrderType getOrderType() { return orderType; } public void setOrderType(CustomOrder.OrderType type) { this.orderType = type; return; } public Map getProucts() { return products; } public void addProduct(String product, int number) { products.put(product, Quantity.of(number)); } public boolean removeProduct(String product) { return products.remove(product) != null; } public void resetCart() { orderType = CustomOrder.OrderType.SOMETHING_ELSE; products = new HashMap<>(); } }