// Collection of code snippets by Arne Vajhøj 
// (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) 
package nosql.nitrite;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

public class Order {
    private int orderId;
    private String customer;
    private List<OrderLine> items;
    public Order(int orderId, String customer) {
        this(orderId, customer, new ArrayList<OrderLine>());
    }
    public Order(int orderId, String customer, List<OrderLine> items) {
        this.orderId = orderId;
        this.customer = customer;
        this.items = items;
    }
    public int getOrderId() {
        return orderId;
    }
    public String getCustomer() {
        return customer;
    }
    public List<OrderLine> getItems() {
        return items;
    }
    public BigDecimal getPrice() {
        BigDecimal res = BigDecimal.ZERO;
        for(OrderLine ol : items) {
            res = res.add(ol.getPrice());
        }
        return res;
    }
}
