Purpose: implement the map interface using a binary search tree.

Modify the program you wrote for Assignment 5 so that it stores the BankAccounts in a map (implemented as a binary search tree) instead of in a SimpleList (implemented as a linked list). This will allow BankAccounts to be accessed by a key (the name of the account holder) rather than by a position.

Your program will consist of:

  • the BankAccount class - your BankAccount class will need an overloaded insertion operator (operator<<).
  • a well decomposed program that does the following:
    • creates an empty Map
    • opens a file that contains a list of commands to be executed. The possible commands are: add a BankAccount (A name balance) remove a BankAccount (R name) deposit an amount to BankAccount (D amount name) withdraw an amount from a BankAccount (W amount name) display (ordered by name) the name and balance of all the BankAccounts in the Map (O)
  • a Map class - this class will implement the map interface discussed in class. It will use a binary search tree to store the BankAccounts. Use the map.h file available here. The public part of the Map class serves as a contract. The map.cpp file must implement the behavior it describes. The program must do its job using the methods described in the map.h file. DO NOT MAKE any changes to the map.h file (other than in the private part of the class definition). If you think that a change is necessary - send a message to the ESG explaining what change you think is needed and why it is needed.
  • Since the Map class uses heap memory space, it needs the big 3 methods. Recommendation: make sure everything else is working before implementing these methods. Since the Map class does not allocate memory space for BankAccounts it should not delete the memory space for BankAccount objects. It does need to delete all heap memory space that it allocated (the nodes of the BST).

An example of a file containing commands to be executed follows:


A Margaret 50
A Itai 250
A Yagmur 150
A Itai 125
O
D 25 Yagmur
W 50 Itai
D 100 Margaret
D 50 Carol
O
R Margaret
R Itai
R Jim
O

The output from processing these commands should look something like:

Itai already has an account - not added

Number of accounts: 3
Itai 250
Margaret 50
Yagmur 150

Carol does not have an account - no deposit made

Number of accounts: 3
Itai 200
Margaret 150
Yagmur 175

Jim does not have an account - not removed

Number of accounts: 1
Yagmur 125

All of the output, including the error messages, should come from the program (not the Map class methods).

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.