/* * Name: listBankAccount.cpp * Function: create and manage a linked list of BankAccountNode * Author: Hui Yang * Date: Oct. 2008 In plain English: Create a class in a class and start with *head newclasshere. That class is going to have the bank data and functions. Submission instruction: for this homework, you only need to submit the electronic copy, i.e., the zip file, on iLearn. Due by: 11:55PM, Friday, November 21 Problem description: The source code posted under Week #11 implements a linked list of bank accounts in its simplest form. However, this program only implements each individual node as an object of the class BankAccountNode. Instead of implementing a linked list as an abstract data type (i.e., class), this program declares a linked list as a pointer (i.e., the head pointer) and then uses standalone functions to manipulate such a linked list. In this homework, you are required to implement such a linked list as an abstract data type listBankAccount, which consists of the following functions: * Initialization: define at least one constructor to initialize a linked list. * frontInsert(): insert a node to the front of a list. * endInsert(): insert a node to the end of a list. * isEmpty(): check whether a list is empty. * searchAccount(): search whether a node is on the list given an account ID. * updateAccount(): given an account ID, first search whether it exists on the list. If yes, update its checking balance as specified by a parameter. * deleteAccount(): given an account ID, first search whether it exists on the list. If yes, delete this node. * printList(): print all the nodes on a list. * destructor: release a linked list to the freestore. Write a test driver to test your code. Note: you can reuse the source code posted on iLearn. */ #include "BankAccountNode.h" int main() { int id; BankAccountNode *head=NULL; BankAccountNode *curr=NULL, *prev=NULL, *next=NULL, *newNode=NULL; //create a head node head = new BankAccountNode(2, 22, 222, NULL); //add a node to the front newNode = new BankAccountNode(1, 11, 111, NULL ); head = frontInsert( head, newNode); //add a node to the end newNode = new BankAccountNode(4, 44, 444, NULL ); head = endInsert( head, newNode); traverseLink( head ); for (id = 1; id<=4; id++ ){ if ( curr=searchAccount(head, id ) ) { cout << "Account " << id << " found; "; curr->output(); } else cout << "Account " << id << " does not exist!\n"; }//for deleteLink(head); }//