import java.text.NumberFormat;
import java.util.ArrayList;

public class Invoice
{
    private ArrayList<LineItem> lineItems;

    public Invoice()								//constructor
    {
        lineItems = new ArrayList<LineItem>();
    }

    public ArrayList<LineItem> getLineItems()
    {
        return lineItems;
    }

    public void addItem(LineItem lineItem)
    {
        this.lineItems.add(lineItem);
    }

    public double getInvoiceTotal()					//compute invoice total
    {
        double invoiceTotal = 0;
        for (LineItem lineItem : this.lineItems)
        {
            invoiceTotal += lineItem.getTotal();
        }
        return invoiceTotal;
    }

    // a method that returns the invoice total in currency format
    public String getFormattedTotal()
    {
        NumberFormat currency = NumberFormat.getCurrencyInstance();
        return currency.format(this.getInvoiceTotal());
    }
}