This assignment adds methods to the SimpleList class and then uses that class to store and make changes to a collection of BankAccounts. Your program must not have any memory leaks.
Your program will consist of:
the BankAccount class used in the Feb.19 lab - no changes are needed
the SimpleList class from the Feb.26 lab with the following additions/changes
change ElementType from int to BankAccount*
add to the display method a line that sends the size of the SimpleList to the output stream
add a method to remove the element at position i void remove(int position);
add a method to get the element at position i ElementType get(int position)const;
add a destructor
~SimpleList();
add a copy constructor
SimpleList(const SimpleList & listToCopy);
add an assignment operator
SimpleList& operator=(const SimpleList & listToCopy);
At the beginning of each of the big 3 methods put a line that sends to cout a message indicating that the method has been called.
a well decomposed program that does the following:
creates an empty SimpleList
opens a file that contains a list of commands to be executed. The possible commands are:
add a BankAccount at a position (A name balance position)
remove the BankAccount at a position (R position)
deposit an amount to the BankAccount at a position (D amount position)
withdraw an amount from the BankAccount at a position (W amount position)
display the name and balance of all the BankAccounts in the SimpleList (O)
the last thing the program should do is to call a function that tests the big 3 methods. You may use the function shown below to do this:
An example of a file containing commands to be executed follows:
A Margaret 50 0 A Itai 250 0 A Yagmur 150 1 O D 25 1 W 50 1 D 100 2 O R 2 R 0 O
The output from processing these commands should look something like:
Number of accounts: 3 Itai 250 Yagmur 150 Margaret 50
Number of accounts: 3 Itai 250 Yagmur 125 Margaret 150
Number of accounts: 1 Yagmur 125
When your program is graded it will be run with the valgrind tool which will check to see if your program creates any memory leaks. It is strongly recommended that you run your program with valgrind. The use of valgrind will be covered in lab on March 5.
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.