Assignment 1 - Accounts Program

advertisement
COP3530 – Data Structures
Homework Assignment 1
This assignment consists of three parts.
1
Part I.
Test an existing program (Account.cpp) to see if it works correctly.
Specifications:
 The program supports two types of accounts: Standard and Student
 After the account is created, the program display the starting balance of the account, which should be
zero.
 Each type of account supports the following functions:
deposit, withdraw, get balance and print history.
 deposit and withdraw should fail if there are insufficient funds.
 getBalance should get the posted balance. The balance should never be less than 0.
 deposit normally accepts a positive number which it then adds to the balance.
 withdraw normally accepts a positive number which it then subtracts from the balance.
 Standard accounts have no fees.
 Student accounts should have a .50 fee for both deposits and withdraws. There should be sufficient
funds to cover the fees as well as the deposit/withdraw.
 printHistory should print a history of all successfully posted transactions.
 The history should have separate entries for withdraws, deposits and fees
Your job: come up with test cases. Your test cases should:
 Test for operations that would result in negative balances.
 Test for operations that would result in positive balances.
 Test for operations that would result in a zero balance.
 Test for fees being charged for transaction on student accounts.
 For student accounts, test withdrawing the balance minus 25 cents. Note that this should fail.
 Test that the balance returns correctly
 Test that printHistory works correctly
1. Write down each test case, and the result you expect.
2. Run the program at least twice (once for a standard account and once for a student account)
3. Try all the test cases and document what you got. Note any places where what you expected was
not what you got.
Part II
Modify the account program to correctly charge fees on student accounts, and record appropriate
additional transactions.
Part III
Retest the program after modifications
Turn in the test cases and results. Also turn in a hard copy of the modified account program. Due Friday,
May 11, 2007.
Download