UMBC CMSC 202
UMBC CMSC 202 CSEE | 202 | current 202

CMSC 202 Fall 2003
Project 4

Bank Accounts

Assigned Monday Nov 10, 2003
Design Due Sunday Nov 16, 2003 11:59pm
Program Due Sunday Nov 23, 2003 11:59pm
Updates 12 Nov 2003
F & R has decided to offer a contract enhancement for anyone who wishes to accept. See the Extra Credit section below.

11 Nov 2003
Please note that the requirement that all data members be dynamically allocated carries with two other implied requirements -- that your class provides its own assignment operator and its own copy construtor

10 Nov 2003
In the description of the CheckingAcct class, the prototype for CashCheck( ) was incorrect. The 2nd parameter was shown as an int... it should be double. All references to CashCheck( ) now show the correct prototype.


Objectives


Project Description

Congratulations!!
You have been awarded a large contract to write software for the F & R Savings and Loan. F & R is a small locally owned S & L that offers savings accounts and checking accounts to its customers. However, the owners of F & R forsee a time when other accounts will be offered. Therefore, their software gurus have designed an object-oriented bank account system which you have been hired to implement.

To allow for seamless addition of new account types, the bank account system is designed with an abstract bank account class from which all other account types will be derived. The class heirarchy is shown in the diagram below

Your job is to implement the BankAcct, SavingsAcct, CheckingAcct and Check classes which are described in more detail below. In order to get paid, your classes must pass rigourous testing by F & R. F & R testers will compile and link your code with test programs which they will write. A simple test program, Proj4.cpp is provided for your initial testing and can be copied from Mr. F's public directory. Other test programs will be used for final testing!

Class Descriptions

The class descriptions below must be followed exactly. You and the F & R software team have agreed upon all class interfaces, so the F & R team expects that your files, classes and their public methods will be named exactly as listed below. Deviation from these agreed upon names will result in breach of contract since your code will not link with the test code from F & R.

You and F & R have agreed on the following implementation rules. Failure to follow these rules will result in a reduction of your compensation.

Also note that the data in these accounts is very sensitive. F & R expect that you will implement all possible security measures to protect their data.

  1. No friends allowed
  2. No public methods other than those specified below are permitted (you may create whatever private methods you deem necessary).
  3. Since the BankAcct class does not provide accessors, some (not all) of the data members of the BankAcct class may be "protected".

The Base Bank Account class

The generic bank account class at the top of the hierarchy must be named BankAcct. Its interface must be found in BankAcct.h and implemented in BankAcct.cpp. Note that this class is an abstract base class. The BankAcct class supports the following interface
  1. a default constructor
  2. BankAcct ( const string& name, int number) - an alternative constructor.
    name is the name of the account owner
    number is the account number
  3. a destructor
  4. void Deposit( double amount) -- deposits money into the account
    amount is the deposit amount in dollars and cents
  5. void Withdraw( double amount) -- withdraws money from the account
    amount is the withdraw amount in dollars and cents. It is an error if the withdraw amount is greater than the current balance.
  6. double Balance(void) -- a "pure virtual" function that returns the the account balance in dollars and cents
  7. void Print( ostream& out = cout ) -- a virtual function that prints the bank account information. The default behavior is to print the account owner's name, the account number, the number and amount of the deposits and withdraws and the balance. See the sample output below for an acceptable format.

Saving Account

The savings account is implemented in the SavingsAcct class. The SavingsAcct class is implemented in SavingsAcct.cpp and its interface is defined in SavingsAcct.h as described below. The SavingsAcct class is derived from the BankAcct class.
  1. a default constructor
  2. SavingsAcct( const string& name, int number, double rate) -- an alternative constructor
    name is the name of the account owner
    number is the account number
    rate is the interest rate (5.00 = 5%)
  3. a destructor
  4. void Print( ostream& out = cout ) which prints the details of the savings account. In addition to the information provided by the BankAcct, the interest rate, interest amount (rate * balance) and account balance are also printed. See the sample output below for an acceptable format.
  5. double Balance( void ) -- returns the account balance in dollars and cents
  6. The insertion operator (operator<<) must also be provided for the SavingsAcct class.

Checking Account

The checking account is implemented in the CheckingAcct class. The CheckingAcct class is implemented in CheckingAcct.cpp and its interface is defined in CheckingAcct.h as described below. The CheckingAcct class is derived from the BankAcct class. The CheckingAcct can support an unlimited number of cashed checks.
  1. a default constructor
  2. CheckingAcct( const string& name, int number) -- an alternative constructor
    name is the name of the account owner
    number is the account number
  3. a destructor
  4. void Print( ostream& out = cout ) which prints the details of the checking account. In addition to the information provided by the BankAcct, a list of cashed checks, the number and total of all checks cashed and the account balance are also printed. See the sample output below for an acceptable format.
  5. double Balance( void ) -- returns the account balance in dollars and cents.
  6. void CashCheck(int checkNr, double amount ) -- adds the check to the list of cashed checks. If the check amount is greater than the current account balance a negative account balance results. Multiple checks with the same number are permitted. Like all other amounts, the check amount is in dollars and cents.
  7. The insertion operator (operator<<) must also be provided for the CheckingAcct class.

To support the implementation of the CheckingAcct class, you will also implement a class to model a check, cleverly named Check. The Check class is implemented in Check.cpp and its interface is defined in Check.h as described below.

  1. a default constructor
  2. Check (unsigned int checkNr, double amount)
    checkNr is the check number
    amount is the check amount in dollars and cents
  3. unsigned int GetCheckNr(void) - accessor for the check number
  4. double GetCheckAmt(void) - accessor for the check amount
  5. a destructor

Other project requirements

  1. To support F & R's plans for future account types, you will supply the polymorphic function
    void PrintAllAccts( const vector< BankAcct * >& accounts).
    The prototype for this function is found in BankAcct.h and it is implemented in BankAcct.cpp.

    The parameter accounts is a const vector of pointers to BankAcct objects which is passed by reference. This function uses polymorphism to print the details of all accounts pointed to by the vector.

  2. Because the F & R gurus are semi-senile they require that all private and protected data members of your classes be dynamically allocated.

Sample Output

This sample output shows how a savings account (9876) and a checking account (1234567) might be printed. Any reasonable format is accepted, provided all required information is present (see the Print() method descriptions above). The details of each account should be clearly separated from other accounts.

Although not shown in this example, negative account balances are possible and should be enclosed in parentheses when printed.

Copy Proj4.cpp from Mr. F's public directory to obtain output similar to the output below.

linux3[18]% Proj4 Acct Number: 9876 Owner : Mr. Raouf 2 Deposits totaling 70.25 2 Withdraws totaling 32.50 Dep/WD Total: 37.75 Interest at 5.00% 1.89 Account Balance: 39.64 --------------------- Acct Number: 1234567 Owner : Mr. Frey 1 Deposits totaling 500.00 1 Withdraws totaling 2.45 Dep/WD Total: 497.55 Checks: 101 4.00 102 14.00 110 24.00 Check Total( 3): 42.00 Account Balance: 455.55 ---------------------

Extra Credit

As is apt to happen, F & R has requested a last minute change to your contract. They are willing to pay and additional 10% for completion of this extra work. This work is optional. You are under no obligation to complete the work.

To be rewarded with extra compensation, your project must provide the following extra functionality, based on the design agreed to by your software development team and the F & R gurus described below.

These changes must be implemented with no changes to the public interface of any class already specified in the project description.

F & R desires that a list of all deposit and withdraw amounts be printed as part of the BankAcct statement (like the checks in the CheckingAcct), rather than just the number and total deposit and withdraw amounts (which are still required). The new account statement might look like the one shown below, but any readable format is acceptable. To facilitate this change, and with a view toward future enhancements, your team and the F & R gurus have designed a new class - the Transaction class. The Transaction class contains the amount of the transaction along with appropriate constructor(s), destructor and accessor(s). The overloaded output operator (operator<<) is also required. The Check class will now be derived from the Transaction class since, in addition to the amount of the check, there will also be a check number.

Questions about this new requirement should be directed to the F & R bulletin board.

linux3[18]% Proj4 Acct Number: 9876 Owner : Mr. Raouf 2 Deposits totaling 70.25 60.00 10.25 2 Withdraws totaling 32.50 25.50 7.00 Dep/WD Total: 37.75 Interest at 5.00% 1.89 Account Balance: 39.64 --------------------- Acct Number: 1234567 Owner : Mr. Frey 1 Deposits totaling 500.00 500.00 1 Withdraws totaling 2.45 2.45 Dep/WD Total: 497.55 Checks: 101 4.00 102 14.00 110 24.00 Check Total( 3): 42.00 Account Balance: 455.55 ---------------------

If you opt for the extra work, please submit a README file with your project to alert the grader that your project supports the extra credit functionality.


Free Advice and Information

  1. Mr. F's public directory for this project is /afs/umbc.edu/users/d/e/dennis/pub/CMSC202/p4
  2. Data members in the BankAcct (base) class which are need by the derived classes should be made "protected" if no accessor is available. Data member that are not needed by the derived classes should be private.
  3. operator<< is NOT a member function of your class and CANNOT be a friend.
  4. As discussed in class, any class that has any (pure) virtual function should have a virtual destructor.
  5. As in project 3, don't duplicate information (such as the number of checks)
  6. Unsatisfied preconditions that would lead to errors must be detected in your class implementations. The actual handling of the error (ie printing an error message) is the responsibility of the user.
  7. Security issues are best handled in your class' destructors.
  8. Create a working solution WITHOUT dynamically allocated data members first and submit that. It's not too hard and somewhat mechanical to change the data members to be pointers after your code is working.

Project Design Assignment

Your project design document for project 4 must be named p4design.txt. Be sure to read the
design specification carefully. Submit your design in the usual way: submit cs202 Proj4 p4design.txt

Project Makefile

For this project, you will be responsible for providing your own makefile. Typing "make" should compile and link all files for your project. Your makefile should also support the commands "make clean" and "make cleanest". If you start with the makefile for project 3, the changes for project 4 are straightforward.


Grading

The grade for this project will be broken down as follows. A more detailed breakdown will be provided in the grade form you recieve with your project grade.

85% - Correctness

This list may not be comprehensive, but everything on this list will be verified by the graders.

15% - Coding Standards

Your code adheres to the
CMSC 202 coding standards as discussed and reviewed in class.

Project Submission

For this project, you will create and submit the following files
  1. BankAcct.h and BankAcct.cpp -- the definition and implmentation of the BankAcct class as well as the prototype and implementation of the PrintAllAccts() function
  2. SavingsAcct.h and SavingsAcct.cpp -- the definition and implementation of the SavingsAcct class
  3. CheckingAcct.h and CheckingAcct.cpp -- the definition and implementation of the CheckingAcct classes
  4. Check.h and Check.cpp - the definition and implementation of the Check class
  5. your makefile
To submit your files, use the usual command submit cs202 Proj4 <list of files> The order in which the files are listed doesn't matter and not all files must be submitted at the same time. However, you must make sure that all files necessary to compile your project (using the makefile) are submitted before the project deadline.

You can check to see what files you have submitted by typing

submitls cs202 Proj4

More complete documentation for submit and related commands can be found here.

Remember -- if you make any change to your program, no matter how insignificant it may seem, you should recompile and retest your program before submitting it. Even the smallest typo can cause compiler errors and a reduction in your grade.

Avoid unpleasant surprises!
Be sure to use the submitmake and submitrun utilities provided for you to compile, link and run your program after you've submitted it.


Last Modified: Wednesday, 12-Nov-2003 18:36:14 EST