Due Date: Wednesday, Nov 26, 8:30 AM
Program Six will demonstrate the use of classes. In this program you
will be implementing a banking system. With this system, users can
access their bank accounts from one or more ATMs (Automated Teller
Machines). Each account is associated with a bank, and each ATM is
associated with a single bank. A bank can be be associated with several
accounts and several ATMs, however.
You will write the code for
the ATM (Automated Teller Machine) class, and the Account
class. We have provided you with a header file for each of the classes,
bank.h,
atm.h,
and account.h. You should not need to modify
these header files (so don't!) The only
file you will need to modify is atm.cpp. This file
contains a skeleton for the member functions you will need to write. The
file also includes some functions (such as main) which we have
provided for you.
The Bank ClassThe Bank class has been provided for you as an object file (you will not have access to the source file). You will need to add the file bank.obj to your project (see Getting Started for information on how to add this file to your project). The definition of the Bank class is provided in the file bank.h.The Bank class consists of multiple accounts, and provides methods for making deposits, withdrawals, and balance inquiries. The class also provides methods for verifying account ID's and PIN numbers. For simplicity, new accounts cannot be created and current accounts can not be deleted. The current accounts, associated with each Bank object are loaded from an input file which is specified in the constructor. The Bank class performs most of it's tasks by calling member functions of the appropriate account. The ATM ClassEach ATM has a Bank associated with it, along with other properties, such as a name, the number of transactions processed, the amount of money available, etc. The definition of the ATM class can be found in atm.h.Each ATM object has a limited amount of cash (initially specified in the constructor). Cash that has been deposited at the ATM is added to this pool of cash, while cash withdrawals are taken from this pool of cash. If a withdrawal is requested for more cash than the ATM object has available, then an error message should be displayed, and the withdrawal denied. The ATM class has member functions for logging a customer in, logging a customer out, withdrawing, and depositing money from the current user's account, and checking the current balance of the user's account. Each transaction the user performs (transactions are: withdrawals, deposits, and balance checks) should be added to a receipt, which can be printed when the user logs out of the ATM machine (i.e. when the logout method is called). You can make your receipt as fancy as you want, as long as it contains the basic information. The sample executable has a fairly fancy receipt. The ATM class performs most of its tasks by calling methods of the Bank class with which the ATM is associated. (Note that there is no direct connection between ATM objects and Account objects!) The Account ClassThe Account class is responsible for keeping track of the current balance of an account, as well as the ID and PIN number of the account and the account owner's name.The Account class has member functions for updating the current balance for an account, returning the current balance, as well as methods for checking ID's and PIN numbers. Lastly, the += and -= operators have been overloaded for performing deposits and withdrawals, respectively. The Account class should not handle checking to make sure the amount of money in the account stays positive -- this is up to the Bank object which holds the Account. Getting StartedYou will need to do the following before you can start working on this assignment:
Data Files and TestingThe data files for this program are all in theP:\course\cs302\public\html\C++\atm\ directory. We have this
path defined as a constant string given at the top of atm.cpp. If
you wanted to change this directory, you should just have to change the
string.
Bank objects need to be passed the name of a file inside their constructor. This file contains the information about their accounts. Currently the program will always look at the file "tyme.dat" in the directory given above, but again, you may wish to change that for testing purposes. We have provided two means of testing your ATM and account code, by keyboard input or by file input. In both cases the format of the interaction with the ATM is the same -- it's just the input type that differs. You give input as a series of transactions followed by the word END. Files should have END as their last line. Each transaction starts off with the name of the ATM it's directed to: either "state", "grocery", or "CS". You can abbreviate these with their first letter and case doesn't matter. After that, the transaction is a series of commands ending with a Logout command. Possible commands are:
P:\course\cs302\public\html\C++\atm\trans1.dat
If you would like to use this file, you can just type "trans1.dat" when
the program asks you what file to use, since the P:\...\atm\ path is
hard-coded in by default (see start of this section).
Handin ProcedureElectronically submit one C++ source file, called "atm.cpp" and an executable called "program6.exe" (all lower case). You will not receive full credit for this assignment if your source files are improperly named or if you handin any other files besides those.Hints
|