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.
You must complete the implementation (.cpp files) of the BankAccount, CheckingAccount, and SavingsAccount classes.
Note: Program must be on the server (kermit) and be able to be compiled and run.
This code is also available on kermit at ~dklick/examples/bank/TestBankAccount.cpp
#include "BankAccount.h" #include "CheckingAccount.h" #include "SavingsAccount.h" #include <iostream> using std::cout; int main(int argc, char* argv[]) { BankAccount b1("Ralph"), b2("Ann", 27.51); CheckingAccount c1("Jack", 1000, 800, 0.06, 15.00); CheckingAccount c2("Lisa", 450); CheckingAccount c3("Andy", 750, 20, 0.57, 120.00); CheckingAccount c4(c3); CheckingAccount c5(c3); c4.setAccountNumber("Alice"); c5 = c2; c5.setAccountNumber("Maxwell"); SavingsAccount s1("Samir", 9300); SavingsAccount s2("Rita", 32); cout << "Initial bank accounts ****\n"; cout << b1 << '\n'; cout << b2 << '\n'; cout << c1 << '\n'; cout << c2 << '\n'; cout << c3 << '\n'; cout << c4 << '\n'; cout << c5 << '\n'; cout << s1 << '\n'; cout << s2 << '\n'; cout << "\nBank accounts so far: " << BankAccount::getCount() << '\n'; { SavingsAccount s3(s2); cout << "\nAfter creating another: " << BankAccount::getCount() << '\n'; } cout << "\nAnd then deleting one: " << BankAccount::getCount() << '\n'; cout << "\nAfter changing accounts:\n"; b1.setAccountNumber("Melvin"); b1.withdraw(50.00); c3.setInterestRate(c3.getInterestRate() - 0.50); c3.setServiceCharge(c3.getServiceCharge() - 110.00); c3.setMinimumBalance(c3.getMinimumBalance() + 580.00); s2.setInterestRate(s2.getInterestRate() + 0.05); cout << b1 << '\n'; cout << c3 << '\n'; cout << s2 << '\n'; cout << "\nAfter posting interest *****\n"; c1.postInterest(); c2.postInterest(); c3.postInterest(); s1.postInterest(); s2.postInterest(); cout << c1 << '\n'; cout << c2 << '\n'; cout << c3 << '\n'; cout << s1 << '\n'; cout << s2 << '\n'; cout << "\nTrying to do withdrawals:\n"; double amtc1 = 250.00, amtc2 = 300.00, amtc3 = 100.00; double amts1 = 120.00, amts2 = 290.00; cout << c1.getAccountNumber() << "'s account "; cout << (c1.verifyMinimumBalance(amtc1) ? "has sufficient funds\n" : "will go below the minimum balance\n"); cout << c2.getAccountNumber() << "'s account "; cout << (c2.verifyMinimumBalance(amtc2) ? "has sufficient funds\n" : "will go below the minimum balance\n"); cout << c3.getAccountNumber() << "'s account "; cout << (c3.verifyMinimumBalance(amtc3) ? "has sufficient funds\n" : "will go below the minimum balance\n"); c1.writeCheck(amtc1); c2.writeCheck(amtc2); c3.writeCheck(amtc3); s1.withdraw(amts1); s2.withdraw(amts2); cout << "\nAfter withdrawing money *****\n"; cout << c1 << '\n'; cout << c2 << '\n'; cout << c3 << '\n'; cout << s1 << '\n'; cout << s2 << '\n'; cout << "\nTrying to do a couple more withdrawals:\n"; if (c1.withdraw(150.00)) cout << "Withdrew"; else cout << "Failed to withdraw"; cout << " $150.00 from " << c1.getAccountNumber() << "'s account\n"; if (c1.withdraw(50.00)) cout << "Withdrew"; else cout << "Failed to withdraw"; cout << " $50.00 from " << c1.getAccountNumber() << "'s account\n"; if (c2.writeCheck(50.00)) cout << "Withdrew"; else cout << "Failed to withdraw"; cout << " $50.00 from " << c2.getAccountNumber() << "'s account\n"; if (c3.writeCheck(105.00)) cout << "Withdrew"; else cout << "Failed to withdraw"; cout << " $105.00 from " << c3.getAccountNumber() << "'s account\n"; if (c3.writeCheck(800.00)) cout << "Withdrew"; else cout << "Failed to withdraw"; cout << " $800.00 from " << c3.getAccountNumber() << "'s account\n"; cout << "\nAfter final withdrawals *****\n"; cout << c1 << '\n'; cout << c2 << '\n'; cout << c3 << '\n'; return 0; }
Initial bank accounts **** Bank account: Ralph, Balance: $0.00 Bank account: Ann, Balance: $27.51 Checking account: Jack, Balance: $1000.00 Checking account: Lisa, Balance: $450.00 Checking account: Andy, Balance: $750.00 Checking account: Alice, Balance: $750.00 Checking account: Maxwell, Balance: $450.00 Savings account: Samir, Balance: $9300.00 Savings account: Rita, Balance: $32.00 Bank accounts so far: 9 After creating another: 10 And then deleting one: 9 After changing accounts: Bank account: Melvin, Balance: $-50.00 Checking account: Andy, Balance: $750.00 Savings account: Rita, Balance: $32.00 After posting interest ***** Checking account: Jack, Balance: $1060.00 Checking account: Lisa, Balance: $468.00 Checking account: Andy, Balance: $802.50 Savings account: Samir, Balance: $9858.00 Savings account: Rita, Balance: $35.52 Trying to do withdrawals: Jack's account has sufficient funds Lisa's account will go below the minimum balance Andy's account has sufficient funds After withdrawing money ***** Checking account: Jack, Balance: $810.00 Checking account: Lisa, Balance: $148.00 Checking account: Andy, Balance: $702.50 Savings account: Samir, Balance: $9738.00 Savings account: Rita, Balance: $35.52 Trying to do a couple more withdrawals: Withdrew $150.00 from Jack's account Withdrew $50.00 from Jack's account Withdrew $50.00 from Lisa's account Withdrew $105.00 from Andy's account Failed to withdraw $800.00 from Andy's account After final withdrawals ***** Checking account: Jack, Balance: $580.00 Checking account: Lisa, Balance: $78.00 Checking account: Andy, Balance: $587.50