I wrote most of a simple bank software program for an intro class in C++ using Visual C++ 2010, however apparently it needs to be an in-memory database (didn't notice that...) which I have never done before and I'm unsure how to go about it.
The program needs to have three interfaces.
The first is a customer interface that lets you check balance of an account, transfer funds between the various accounts (I only made accounts for checking, savings, and a credit line), and make deposits and withdrawals from specific accounts.
The second is a bank teller interface, which has access to the customer interface (it can modify the account data the same way), which isn't exactly hard to do. Anyway, it also needs to be able to add and delete users, and use a sequential search based on a customer's name.
The accounts are made with a struct that had the name, PIN, and amounts in each account type that was just saved to a file in order (the first two lines were the name, the third the PIN, and the last three the accounts, so when someone dealt with transfers or something I just targeted the line it was on and pulled out that info to put into a variable for modification, then overwrote the line with the new number). The search function took input from two strings where the name was put in at, and then compared them to the first two lines of a text file until it found the right file, then displayed it and from there the user could modify or delete the file.
The last interface is a management UI, which has the same powers as the teller UI, and then it would have options to list number of customers in the database, the cumulative amount of money in the bank, and then lists of deposits and withdrawals in a day and a log of all transactions.
To do this bit I just had different text documents that were searched through.
For the transaction details I had one text document, to which a new line was added every time there was a change (the line would be like "01302011 SAVE 100.00 W 20.00 80.00 JOHN DOE 12:00:00", where the first number is the date, SAVE indicates the saving's account, 100.00 is the balance before any action is taken, W mean's withdrawal, 20.00 is the amount withdrawn, 80.00 is the amount left, then the name of the customer and the date).
For the amount of customers and the amount of money in the bank, I had two other text files. One stored the amount of money in the bank. Anytime there was a change, it would put that number into a float that was modified and then overwrote the first line. The other had a list of the names of each customer, each customer stored on one line. The first line was the number of customers.
And to be honest I have no clue how I would do this as an in-memory DB. I've never even tried to make one before.
I'm guessing that I need to do something like create an array of structs.
So off the top of my head I would do something like:
1 2 3 4 5 6 7 8
|
int arraysize;
struct AccountData
{
char[20] firstname;
char[20] lastname;
float checking = 0, savings = 0, creditcard = 0;
} account[arraysize];
|
to set up the basic struct array?
I'm not entirely sure how I would set up a dynamic array though, so that every time you add an account it dynamically adds one to the arraysize. Especially given that adding an account would be it's own function, so when I go back how would I test to see what index I'm on (if I were to be adding a fifth account, it would need to go to index 4 for the array so would I just use the increment operator on arraysize? Is there a way to be sure it does it right every time, as I need to initialize it to 0 at the start so that it assign the proper index to the structs?)
And how should I organize it? I can't use any global variables, so with everything localized how would I get the information saved in that struct if I were in a different function, such the search function instead of addcustomer? I know I could use pointers, but how would I carry the address data across functions, or would I not need to for some reason?
If anyone has any tutorials regarding this or can explain parts of it to me, it would be greatly appreciated.