Cs102 Spring 2005 Lab4
Due Date: Monday April 25th by midnight
In this lab you will develop a very simple graphical interface to allow
a bank teller access to a customer's bank account. You will work
with inheretance and polymorphism in this lab.
In this lab you will
- Implement the is-a (inheritance) relationship
- Work with polymorphism in C++
- method over-riding
- virtual functions
- using base class pointer variables to point at child class
You will create two new classes: checkingAccount and savingsAccount.
The classes will extend (inherit from) the existing Account class. You
will then have to initialize the two account member variables in the
Customer class. You will also have to fill in the body of the methods
The UML for this lab is found below:
- Customer::handleDeposit: This method must query the user for the
amount to deposit, and then call the deposit method on the appropriate
- Customer::handleWithdraw: This method must query the user
for the amount to be withdrawn. If the amount to be withdrawn is less
than the current balance, then reduce the balance by that amount. If
the amount is over the current balance, then behave as followes
- if the selected account is the savings account, then print
out/display a firm but polite warning message indicating that the
Customer does not have the funds
- if the selected account is the checking account, deliver a
warning message and then charge the account an "overdraft penalty" of
- Customer::monthlyMaintenance: perform the monthly maintanace on
- checking account: If the balance is over $400 then no change,
but if the balance is under $400, then make a $4.50 charge (reduction
of the balance)
- Savings account: add interest for the savings account of 1% to
the total balance of the account.
Beginning your work
Once again you are not starting from scratch. You will start with the
files that are set up for you.
copy lab4.zip from my directory as you have copied files for previous
unzip the files in your directory and cd into the lab4 directory that
Compile the files that are there using the command
Your executable will also be called Lab4.
I suggest that you begin by stubbing
out the SavingsAcct and CheckingAcct classes. Create the
header and cpp files and add the three methods, but don't put any code
into the methods yet.
Next you should probably finish implementing the has-a relationship
between the Customer class and the two account classes by initializing
the two Account pointers with the appropriate objects.
Finally, iteratively finish the lab by working on the implementation of
one of the three methods discussed above the UML diagram and working on
the associated CheckingAcct and SavingsAcct methods.
When you have finished the lab, remember to include the readme.txt with
the usual information
And zip up your lab4 directory and submit it as usual.
- Your name
- The name of your cpp and h files and the classes that they
- The implementation decisions that you made. Why did you solve the
problem the way that you did.
- Directions on running and using your program. Especially anything
that might not be the same for all students. (example: how will you
query user input for a deposit?)
- and of course any problems or bugs left in your program.