Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Name: Jacob Jimenez
- Section Number: 0146
- Operating System Used: Windows 10
- Compiler used: Visual Studio 2016
- Email: jacob.jime@gmail.com
- Latest date and time program last compiled and ran: 9/21/17 3:51 PM
- */
- #include "BankAccountList.h";
- int main1() {
- BankAccount B1("1234", "Jacob", "Jim", 20.00);
- BankAccount B2("4321", "John", "Doe", 20.01);
- BankAccount B3("9087", "James", "Jones", 20.02);
- BankAccountList BAL;
- BAL.addAccount(B1);
- BAL.addAccount(B2);
- BAL.addAccount(B3);
- cout << BAL.toString() << endl;
- bool found = false;
- int index = -1;
- found = BAL.findAccount("4321", index);
- cout << index << endl;
- bool successfulDep = BAL.depositMoney("9087", 10.01);
- cout << successfulDep << endl;
- bool successfulWith = BAL.withDrawMoney("9087", 10.00);
- cout << successfulWith << endl;
- BAL.sort(1);
- cout << BAL.toString() << endl;
- BAL.sort(2);
- cout << BAL.toString() << endl;
- BAL.sort(3);
- cout << BAL.toString() << endl;
- int whereFound = -1;
- bool isFound = BAL.findAccount("9087", whereFound);
- cout << isFound << whereFound << endl;
- bool ifFound = BAL.deleteAccount("9087");
- cout << ifFound << endl;
- cout << BAL.toString() << endl;
- system("pause");
- return 0;
- }
- int main() {
- bool done = false;
- bool isAdded = false;
- int choice;
- BankAccountList BAL;
- while (!done) {
- cout << "Main Menu" << endl;
- cout << "[1] Add new accounts using keyboard: " << endl
- << "[2] Add new accounts using a data file (Limit = 30 accounts): " << endl
- << "[3] Update an account: " << endl
- << "[4] Close/delete an account: " << endl
- << "[5] Write current account list to an output file in append mode: " << endl
- << "[6] Print current account list to console: " << endl
- << "[7] Withdraw Money from an account: " << endl
- << "[8] Make Deposit to an account " << endl
- << "[9] Balance inquiry " << endl
- << "[10] Search account and show details (console only): " << endl
- << "[11] Print current list description to console only " << endl
- << "[12] Print list sorted by account number to console: " << endl
- << "[13] Print list sorted by last name to console" << endl
- << "[14] Print list sorted by balance to console: " << endl
- << "[15] Exit " << endl;
- cout << "Please enter a choice: " << endl;
- cin >> choice;
- if (choice == 1) {
- BAL.getInstance(BAL);
- isAdded = true;
- }
- else if (choice == 2) {
- // Setup for input file.
- string inFileName;
- cout << "Enter full path to input file: ";
- cin.ignore();
- getline(cin, inFileName);
- //2. Bind file name with the ifstream object - Opening a connection to file
- ifstream in(inFileName);
- if (in.is_open()) {
- BAL.getInstance(BAL, in);
- isAdded = true;
- }
- else {
- cout << "File could not be opened." << endl;
- }
- }
- else if (isAdded && choice == 3) {
- BAL.updateAccount();
- }
- else if (isAdded && choice == 4) {
- string accN;
- cout << "Please enter your account number: ";
- cin >> accN;
- BAL.deleteAccount(accN);
- }
- else if (isAdded && choice == 5) {
- // Setup for input file.
- string outFile;
- cout << "Enter full path to output file: ";
- cin.ignore();
- getline(cin, outFile);
- //2. Bind file name with the ifstream object - Opening a connection to file
- ofstream out(outFile, ios::app);
- if (out.is_open()) {
- BAL.print(out);
- }
- else {
- cout << "File could not be opened." << endl;
- }
- }
- else if (isAdded && choice == 6) {
- BAL.print();
- }
- else if (isAdded && choice == 7) {
- double money;
- string acct;
- cout << "Please enter an account number: " << endl;
- cin >> acct;
- cout << "Please enter a withdrawl amount: $" << endl;
- cin >> money;
- BAL.withDrawMoney(acct, money);
- }
- else if (isAdded && choice == 8) {
- double money;
- string acct;
- cout << "Please enter an account number: " << endl;
- cin >> acct;
- cout << "Please enter a deposit amount: $" << endl;
- cin >> money;
- BAL.depositMoney(acct, money);
- }
- else if (isAdded && choice == 9) {
- string acct;
- cout << "Please enter an account number: " << endl;
- cin >> acct;
- if (BAL.getBalance(acct) >= 0.00) {
- cout << "Balance for account number " << acct << ": " << "$" << BAL.getBalance(acct) << endl;
- }
- else {
- cout << "Account does not exist." << endl;
- }
- }
- else if (isAdded && choice == 10) {
- string acct;
- cout << "Please enter an account number: ";
- cin >> acct;
- int index = -1;
- bool isFound = BAL.findAccount(acct, index);
- if (isFound == true && index != -1) {
- cout << left << setw(25) << BAL.getFirstName(acct) << setw(30) << BAL.getLastName(acct) << setw(30) << BAL.getBalance(acct) << endl;
- }
- else {
- cout << "Account was not found." << endl;
- }
- }
- else if (isAdded && choice == 11) {
- cout << BAL.listDescription() << endl;
- }
- else if (isAdded && choice == 12) {
- BAL.sort(1);
- BAL.print();
- }
- else if (isAdded && choice == 13) {
- BAL.sort(2);
- BAL.print();
- }
- else if (isAdded && choice == 14) {
- BAL.sort(3);
- BAL.print();
- }
- else if (choice == 15) {
- done = true;
- }
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement