swt23w23/src/main/java/catering/order/CustomCart.java

40 lines
784 B
Java
Raw Normal View History

package catering.order;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
@Component
public class CustomCart {
private CustomOrder.OrderType orderType;
private Map<String, Integer> 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<String, Integer> getProucts() {
return products;
}
public void addProduct(String product, int number) {
products.put(product, number);
}
public boolean removeProduct(String product) {
return products.remove(product) != null;
}
}