A long, long time ago, in a galaxy far, far away...
Actually, it was only about 10 years ago, and it was in my basement. I was just getting back into programming with C++, and I took on a programming challenge that I found online.
The challenge:
Create a database for a bank [referred to as Same-Diff Bank, for reasons unknown to this author], that uses binary files to store information about the bank's customers, the customers' accounts, and their account intormation.
It should be secure– using passwords to prevent customers from gaining access to administrative accounts or other customers' accounts.
It should also have at least four classes– a Bank, a Customer, an Account, and it should also have an ATM class for access to Accounts.
Use all the programming skills you have learned up to this point– classes, vectors, pointers, data structures, binary files, etc. |
I started off by creating a UML diagram of what I needed. After approximately 5,000 revisions, I was finally satisfied. Unfortunately, I had some issues with my job which took a couple of weeks to resolve, but I finally got back to it.
After a week of the occasional attempt to start it, I finally made a promise to myself to finish it all in one night (absolutely bonkers). After a hectic 5 hours or so of endless typing, retyping, and eureka moments, I finally had it error/warning-free! Finished!
...Or so I thought. Debugging took another couple hours, as it was riddled with logic errors and stuff that just didn't work. I finally remembered that I could use vectors instead of dynamic arrays, and then I wouldn't have to make a whole bunch of custom functions!
I finally finished around 4 AM, saved my work, and entered
c++ -g -Wall -o same-diff-bank same-diff-bank.cc |
into the terminal, followed by
and was interrupted by a pop-up reminder on my screen saying "Leave for work in 5 minutes." My groan of protest ended up being more of a croak as I called in "sick" and staggered off to bed.
Anyway, after my long and rambling prelude, here is the aforementioned bank project. I didn't want to post the code here, as the headers are rather long (between 200 and 1200 lines), but they're on my Pastebin– here are the links:
Driver:
https://pastebin.com/1PeFcP5y
Bank Header:
https://pastebin.com/7rpKn4sC
Customer header:
https://pastebin.com/stYv3mqA
Account header:
https://pastebin.com/SE54mhwP
ATM header:
https://pastebin.com/HxKwG8Zy
The driver is actually short enough to post here:
1 2 3 4 5 6 7 8
|
#include <iostream>
#include "bank.h"
int main ()
{
Bank SameDiffBank;
SameDiffBank.login();
}
| |
Doesn't seem like much to control headers that are 1200 lines long, but that's C++ for ya.
I originally tried to make this an article, but it hasn't been approved for a few months, and the site admin seems to have taken AWOL, so there you go.
This is...how do I say this...raw code? As in, it doesn't work super well, and I used a weird file format for the binary storage, and there may have been a few issues that I didn't find in the debugger.
Thanks for reading!
max