// acctList.cc
// P. Conrad, 4/6/2005 
// list of accounts

#include "acct.h"
#include "acctList.h"
#include <iostream>
using namespace std;

// constructor makes an empty list of accounts

AcctList_C::AcctList_C()
{
    numAccounts = 0;
    head = NULL;
    tail = NULL;
}


void AcctList_C::addAccount(Acct_C &a)
{
  Node *p;

  p = new Node;
  p->acct = new Acct_C(a.getAcctNum(), a.getName());
  p->next = NULL;

  if (head==NULL)
    head = tail = p;
  else 
    {
      tail->next = p;
      tail = p;
    }
  numAccounts++;
}


void AcctList_C::printAllAccounts()
{
  for (Node *p=head; p!=NULL ; p=p->next)
    cout << "\t" << p->acct->getAcctNum() 
	 << "\t" << p->acct->getName() << endl;

}

// question.. what if you just wrote p->getAcctNum.  Would that work?
// why or why not?














