Lab 15B: Polymorphism

  < Previous  Next >

Objectives:

In this lab, we will practice:

Background

There are a couple of different types of bank accounts. For the purposes of this lab, there are NO generic accounts. There are savings accounts that have a balance and take deposits and withdrawals. Savings accounts also have an interest rate (specified at the time of creation of the account). Additionally, there are checking accounts that have a balance and can have checks drafted against the balance and take deposits and withdrawals.

Assignment:

Write an Account class to be an abstract base class. Choose wisely which method(s) to modify to make it an abstract base class. Additionally, add a SavingsAccount, and a CheckingAccount class, each of which inherits from Account. Make sure you put the common data members and member methods in Account. The driver code must compile and produce the following output:


      

Submission

Submit your source code using the handin program. For handin, for this lab, type the following in a terminal window exactly as it appears:
handin  lab15B  Account.h  Accout.cpp  CheckingAccount.h  CheckingAccount.cpp SavingsAccount.h SavingsAccount.cpp
To verify your submission, type the following in a terminal window:
handin  lab15B

Rubric:

Points  Item
------  --------------------------------------------------------------
10      Documentation
        Header comment block at the beginning of each file with:
        + Your full name
        + Date(s) code was written
        + Description
        Comments explaining the role of each variable and major section of code

40      Correctness
        Program solves the assigned problem using methods described in program description
	+ Account class (has all common members and is an abstract base class)
        + CheckingAccount class (has only members specific to CheckingAccount)
        + CheckingAccount class (has only members specific to SavingsAccount)
        Program compiles without errors
        Program executes without crashing
        Program produces the correct output
------  --------------------------------------------------------------
50      Total

Notes

  1. If you want to match my output exactly, then run the following on ranger:
    g++  lab15B-driver.cpp  Account.cpp  CheckingAccount.cpp  SavingsAccount.cpp  -o accounts
    ./accounts  &>  output.txt
    diff /nfshome/hcarroll/public_html/2170/private/closedLab/lab15B-answerKey.txt  output.txt
    If the two files match exactly (which is what you want) then there should be NO output from diff. If diff shows one or more differences, fix them and run it again. To get side-by-side output (with the answer key on the left and your output on the right), replace the last line with:
    diff  --side-by-side  /nfshome/hcarroll/public_html/2170/private/closedLab/lab15B-answerKey.txt  output.txt
    For details about interpreting the output of diff, see the Using diff section on the Misc. webpage.