CIS 35A: Introduction to Java Programming

Home | Green Sheet | Lectures | Assignments | FAQ | Grades

Dates

Dates and Strings
Dates and times
Invoice

Code that adds a date to the Invoice class

import java.text.*;
import java.util.*;

public class Invoice
{
    private ArrayList lineItems;
    private Date invoiceDate;

    public Invoice()
    {
        lineItems = new ArrayList();
        invoiceDate = DateUtils.getCurrentDate();
    }

    public ArrayList getLineItems(){
        return lineItems;
    }

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

    public double getInvoiceTotal()
    {
        double invoiceTotal = 0;
        for (LineItem lineItem : this.lineItems)
        {
            invoiceTotal += lineItem.getTotal();
        }
        return invoiceTotal;
    }
Previous | GregorianCalendar | Calendar | Date | DateFormat | DateUtils | Invoice | Next