Bank Accounts (Inheritance)

Objectives

  • Implement classes which use inheritance (derived classes, subclasses)
  • Write constructors
  • Write destructors
  • Overload operators (assignment, insertion)
  • Write accessor functions
  • Write mutator functions
  • Correctly program classes that use dynamic memory allocation
  • Correctly use access modifiers for data members
  • Correctly implement static and instance data members and functions

Preliminary steps

  • Create a new directory to hold this assignment: mkdir bank
  • Make the new directory your current working directory: cd bank
  • Copy the starting files into your current working directory: cp ~dklick/examples/bank/* .
  • Change the permissions on the new directory to 700: chmod 700 .

Resources

There are three classes in this assignment. You are given the header files for all three classes and a test driver program for the whole project. You are also given starting files for implementation of the three classes. Your task is to complete the implementation files for the three classes.

The programs you are given are as follows:

The above code is also available on kermit in the ~dklick/examples/bank/ directory.

Requirements

You must complete the implementation (.cpp files) of the BankAccount, CheckingAccount, and SavingsAccount classes.

  • BankAccount.cpp
    • initialize the static int data member
    • implement the init method
    • implement the two constructors
    • implement the destructor
    • implement the assignment operator
    • implement the setAccountNumber method
  • CheckingAccount.cpp
    • implement the constructor
    • implement the three mutator methods
    • implement the postInterest method
    • implement the verifyMinimumBalance method
    • implement the withdraw method
    • implement the insertion operator overload and make sure the formatting matches the sample output
  • SavingsAccount.cpp
    • implement the constructor
    • implement the postInterest method
    • implement the withdraw method
    • implement the insertion operator overload and make sure the formatting matches the sample output

Grading rubric

Note: Program must be on the server (kermit) and be able to be compiled and run.

  • 5 pts: Style conventions are followed and documentation comments have your name, date, etc. in all three source files (.cpp) that you have to modify. The test driver code and the header files should be left as they are.
  • 15 pts: BankAccount.cpp works properly and meets all requirements
  • 15 pts: CheckingAccount.cpp works properly and meets all requirements
  • 15 pts: SavingsAccount.cpp works properly and meets all requirements

Test driver code

TestBankAccount.cpp.txt

This code is also available on kermit at ~dklick/examples/bank/TestBankAccount.cpp

Sample output from running test driver program