//--------------------------------------------------------------------
//
//  Laboratory 4                                       lab04-ex1.cpp
//
//  Copy of example problem in prelab section that demonstrates
//  using an ordered list to read in a set of bank accounts and
//  output the accounts in ascending order based on their account
//  numbers.
//
//--------------------------------------------------------------------

#include <iostream>

struct DataType
{
    int acctNum;              // (Key) Account number
    float balance;            // Account balance
  
    int getKey () const
        { return acctNum; }   // Returns the key
};

#include "ordlist.cpp"

const int maxNameLength = 15;
  
void main()
{
    OrdList accounts;         // List of accounts
    DataType acct;            // A single account
  
    // Read in information on a set of accounts.

    cout << endl << "Enter account information (EOF to end) : "
         << endl;
    while ( cin >> acct.acctNum >> acct.balance )
        accounts.insert(acct);

    // Output the accounts in ascending order based on their account
    // numbers.
  
    cout << endl;
    if ( !accounts.isEmpty() )
    {
       accounts.gotoBeginning();
       do
       {
           acct = accounts.getCursor();
           cout << acct.acctNum << " " << acct.balance << endl;
       }
       while ( accounts.gotoNext() );
    }
}; 


