public void addPurchase(String product, int quantity, double price) { if (lineItems == null) lineItems = new ArrayList<LineItem>(); LineItem item = new LineItem(); item.setOrder(this); item.setProduct(product); item.setQuantity(quantity); item.setSubtotal(quantity * price); lineItems.add(item); total += quantity * price; }