From f2d1216153123a3fbee6af8e7a0ad06a3577f216 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sat, 27 Jun 2020 14:11:01 +0300 Subject: Finished implementation of closing and opening bank accounts. --- CPP/BABS/BankSystem.cpp | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'CPP/BABS/BankSystem.cpp') diff --git a/CPP/BABS/BankSystem.cpp b/CPP/BABS/BankSystem.cpp index 1493451..0b4e726 100644 --- a/CPP/BABS/BankSystem.cpp +++ b/CPP/BABS/BankSystem.cpp @@ -48,9 +48,25 @@ void closeBankAccount() { cout << "Bank account with ID: " << id << " is closed!" << endl; } +void reopenBankAccount() { + cout << "Bank account ID: "; + int id; + cin >> id; + + cout << "Are you really sure you want to reopen bank account with ID: " << id << "? [y/n]"; + char answer; + cin >> answer; + + if (answer == 'y' || answer == 'Y') { + BADatabase[getIndexFromID(id)].reopen(); + } + + cout << "Bank account with ID: " << id << " is closed!" << endl; +} + void bankerMode() { while(true) { - cout << "What do you want to do: [0] Exit, [1] List bank accounts, [2] Open bank account, [3] Close bank account" << endl; + cout << "What do you want to do: [0] Exit, [1] List bank accounts, [2] Open bank account, [3] Close bank account, [4] Reopen bank account" << endl; int value; cin >> value; @@ -60,6 +76,7 @@ void bankerMode() { case 1: listAllAccounts(); break; case 2: openBankAccount(); break; case 3: closeBankAccount(); break; + case 4: reopenBankAccount(); break; } } } @@ -71,6 +88,11 @@ void atmMode() { cout << endl; BankAccount ba = BADatabase[userId]; + if (ba.getCloseStatus()) { + cout << "Bank account is closed!" << endl; + return; + } + while(true) { cout << "What do you want to do: [0] Exit, [1] View balance, [2] Deposit money, [3] Withdraw money?" << endl; @@ -81,7 +103,7 @@ void atmMode() { case 0: return; case 1: cout << ba.getBalance() << endl; break; case 2: cout << "Amount to deposit: "; cin >> value; ba.deposit(value); break; - case 3: cout << "Amount to withdraw: "; cin >> value; ba.deposit(value); break; + case 3: cout << "Amount to withdraw: "; cin >> value; ba.withdraw(value); break; } } } \ No newline at end of file -- cgit v1.2.3