/*
 * Created on Dec 9, 2004
 *
 * Lecture class which contains the main method for examples done
 * in lectures for CS1020-001 Winter 2004-2005. 
 */
package cs1020;

// Added implements Serializable to the Transaction class

import java.io.*;
import java.util.*;

/**
 * @author t a y l o r@msoe.edu
 *
 * Lecture class which contains the main method for examples done
 * in lectures for CS1020-001 Winter 2004-2005. 
 */
public class Lecture {

    /**
     * @author t a y l o r@msoe.edu
     * 
     * @param args Currently ignored
     */
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        File outFile = new File("transaction.out");
        ObjectOutputStream outOS = new ObjectOutputStream(new FileOutputStream(outFile));
        
        Transaction transaction = new Transaction();
        for(int i=0; i<10; ++i) {
            transaction.setAmount(Math.random()*500);
            // outOS.writeObject(transaction);
            outOS.writeUnshared(transaction);
        }
        
        outOS.close();
        
        File inFile = new File("transaction.out");
        ObjectInputStream inOS = new ObjectInputStream(new FileInputStream(inFile));
        
        Transaction[] trans = new Transaction[10];
        for(int i=0; i<trans.length; ++i) {
            trans[i] = (Transaction)inOS.readObject();
            
            System.out.println(trans[i].getAmount());
        }

    }
}