Java Reference
In-Depth Information
10 = new Address( ÐSam's
Small AppliancesÑ ,
11 Ð100 Main StreetÑ,
ÐAnytownÑ, ÐCAÑ, Ð98765Ñ );
12
13 Invoice samsInvoice = new
Invoice(samsAddress);
14 samsInvoice.add( new
Product( ÐToasterÑ , 29.95 ), 3 );
15 samsInvoice.add( new Product( ÐHair
dryerÑ , 24.95 ), 1 );
16 samsInvoice.add( new Product( ÐCar
vacuumÑ , 19.99 ), 2 );
17
18 System.out.println(samsInvoice.format());
19 }
20 }
ch12/invoice/Invoice.java
1 import java.util.ArrayList;
2
3 /**
4 Describes an invoice for a set of purchased products.
5 */
6 public class Invoice
7 {
8 /**
9 Constructs an invoice.
10 @param anAddress the billing address
11 */
12 public Invoice(Address anAddress)
13 {
14 items = new ArrayList<LineItem>();
15 billingAddress = anAddress;
16 }
17
18 /**
19 Adds a charge for a product to this invoice.
20 @param aProduct the product that the customer
ordered
552
553
Search WWH ::




Custom Search