CIS 35A: Introduction to Java Programming

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

Collections

Collections and Generics
Invoice app
Overview

Console output for the Invoice application

Classes used by the Invoice application

Name Description
Product Represents a Product object.
ProductDB Provides a getProduct method that retrieves the Product object for a specified product code.
Validator Provides methods that accept and validate user input.
LineItem Represents an invoice line item, which includes a Product object, a quantity, and a total.
Invoice Represents a single invoice. The line items are represented by an array list.
InvoiceApp Contains the main method for the Invoice application.

The constructor and methods for the Invoice class

Constructor Description
Invoice() Creates an empty invoice.


Method Description
void addItem(LineItem lineItem) Adds the specified line item to the invoice.
ArrayList getLineItems() Returns an ArrayList object that contains the line items for the invoice.
double getInvoiceTotal() Returns a double that contains the sum of the totals for the line items in the invoice.
String getFormattedTotal() Returns a String that contains the invoice total formatted as currency.
Previous | Overview | Invoice class | InvoiceApp class | Next