-
In step 4a-c on page 10-3, your
code might look like:
PurchaseLog pl = new PurchaseLog();
GasPurchase p = new GasPurchase ( 12.12, "1/1/2001" );
pl.addPurchase ( p );
p = new GasPurchase ( 20.01, "2/1/2001" );
pl.addPurchase ( p );
System.out.println ( "Total: " + pl.getTotalAmount() );
-
In Step 4d on page 10-3, your code
might look like (exception handling
omitted):
ObjectOutputStream oos =
new ObjectOutputStream (
new FileOutputStream ( xxxxxx ) );
oos.writeObject ( xxxxx );
oos.close();
-
In Step 6a-c on page 10-3, your
code might look like (exception
handling omitted):
PurchaseLog pl = null;
ObjectInputStream ois =
new ObjectInputStream (
new FileInputStream ( xxxxxx ) );
pl = (PurchaseLog)ois.readObject ();
ois.close();
System.out.println ( "Purchases: " + pl );
System.out.println ( "Total: " + pl.getTotalAmount() );