diff options
| author | Syndamia <kamen.d.mladenov@protonmail.com> | 2020-06-27 14:11:01 +0300 |
|---|---|---|
| committer | Syndamia <kamen.d.mladenov@protonmail.com> | 2020-06-27 14:11:01 +0300 |
| commit | f2d1216153123a3fbee6af8e7a0ad06a3577f216 (patch) | |
| tree | 2c5904a420306a4c742185557f10f158c1d39a1f /CPP | |
| parent | e4bc857f1f7edf677c3ffec8021db57043db350d (diff) | |
| download | Self-learning-f2d1216153123a3fbee6af8e7a0ad06a3577f216.tar Self-learning-f2d1216153123a3fbee6af8e7a0ad06a3577f216.tar.gz Self-learning-f2d1216153123a3fbee6af8e7a0ad06a3577f216.zip | |
Finished implementation of closing and opening bank accounts.
Diffstat (limited to 'CPP')
| -rw-r--r-- | CPP/.codelite/CPP-kamen.tags | bin | 323584 -> 331776 bytes | |||
| -rw-r--r-- | CPP/.codelite/CPP.session | 34 | ||||
| -rw-r--r-- | CPP/BABS/BABS.mk | 2 | ||||
| -rw-r--r-- | CPP/BABS/BankAccount.cpp | 12 | ||||
| -rw-r--r-- | CPP/BABS/BankAccount.h | 4 | ||||
| -rw-r--r-- | CPP/BABS/BankSystem.cpp | 26 | ||||
| -rw-r--r-- | CPP/BABS/main.cpp | 2 | ||||
| -rw-r--r-- | CPP/build-Debug/BABS/BankAccount.cpp.o | bin | 140112 -> 141104 bytes | |||
| -rw-r--r-- | CPP/build-Debug/BABS/BankSystem.cpp.o | bin | 167800 -> 170048 bytes | |||
| -rw-r--r-- | CPP/build-Debug/BABS/main.cpp.o | bin | 38976 -> 39032 bytes | |||
| -rwxr-xr-x | CPP/build-Debug/bin/BABS | bin | 182592 -> 187312 bytes |
11 files changed, 58 insertions, 22 deletions
diff --git a/CPP/.codelite/CPP-kamen.tags b/CPP/.codelite/CPP-kamen.tags Binary files differindex a99dc39..50cd438 100644 --- a/CPP/.codelite/CPP-kamen.tags +++ b/CPP/.codelite/CPP-kamen.tags diff --git a/CPP/.codelite/CPP.session b/CPP/.codelite/CPP.session index c1bf6d4..922ce71 100644 --- a/CPP/.codelite/CPP.session +++ b/CPP/.codelite/CPP.session @@ -1,40 +1,40 @@ <?xml version="1.0" encoding="UTF-8"?> -<Session Name="/home/kamen/Programming/GitHub-repos/CPP/CPP.workspace"> - <int Value="2" Name="m_selectedTab"/> - <wxString Value="/home/kamen/Programming/GitHub-repos/CPP/CPP.workspace" Name="m_workspaceName"/> +<Session Name="/home/kamen/Programming/GitHub-repos/Self-learning/CPP/CPP.workspace"> + <int Value="4" Name="m_selectedTab"/> + <wxString Value="/home/kamen/Programming/GitHub-repos/Self-learning/CPP/CPP.workspace" Name="m_workspaceName"/> <TabInfoArray Name="TabInfoArray"> <TabInfo> - <wxString Value="/home/kamen/Programming/GitHub-repos/CPP/BABS/main.cpp" Name="FileName"/> + <wxString Value="/home/kamen/Programming/GitHub-repos/Self-learning/CPP/BABS/main.cpp" Name="FileName"/> <int Value="0" Name="FirstVisibleLine"/> - <int Value="4" Name="CurrentLine"/> + <int Value="0" Name="CurrentLine"/> <wxArrayString Name="Bookmarks"/> <IntVector Name="CollapsedFolds"/> </TabInfo> <TabInfo> - <wxString Value="/home/kamen/Programming/GitHub-repos/CPP/BABS/BankSystem.h" Name="FileName"/> - <int Value="12" Name="FirstVisibleLine"/> - <int Value="7" Name="CurrentLine"/> + <wxString Value="/home/kamen/Programming/GitHub-repos/Self-learning/CPP/BABS/BankAccount.h" Name="FileName"/> + <int Value="16" Name="FirstVisibleLine"/> + <int Value="17" Name="CurrentLine"/> <wxArrayString Name="Bookmarks"/> <IntVector Name="CollapsedFolds"/> </TabInfo> <TabInfo> - <wxString Value="/home/kamen/Programming/GitHub-repos/CPP/BABS/BankSystem.cpp" Name="FileName"/> - <int Value="32" Name="FirstVisibleLine"/> - <int Value="47" Name="CurrentLine"/> + <wxString Value="/home/kamen/Programming/GitHub-repos/Self-learning/CPP/BABS/BankAccount.cpp" Name="FileName"/> + <int Value="5" Name="FirstVisibleLine"/> + <int Value="51" Name="CurrentLine"/> <wxArrayString Name="Bookmarks"/> <IntVector Name="CollapsedFolds"/> </TabInfo> <TabInfo> - <wxString Value="/home/kamen/Programming/GitHub-repos/CPP/BABS/BankAccount.h" Name="FileName"/> - <int Value="11" Name="FirstVisibleLine"/> - <int Value="6" Name="CurrentLine"/> + <wxString Value="/home/kamen/Programming/GitHub-repos/Self-learning/CPP/BABS/BankSystem.h" Name="FileName"/> + <int Value="0" Name="FirstVisibleLine"/> + <int Value="0" Name="CurrentLine"/> <wxArrayString Name="Bookmarks"/> <IntVector Name="CollapsedFolds"/> </TabInfo> <TabInfo> - <wxString Value="/home/kamen/Programming/GitHub-repos/CPP/BABS/BankAccount.cpp" Name="FileName"/> - <int Value="12" Name="FirstVisibleLine"/> - <int Value="41" Name="CurrentLine"/> + <wxString Value="/home/kamen/Programming/GitHub-repos/Self-learning/CPP/BABS/BankSystem.cpp" Name="FileName"/> + <int Value="75" Name="FirstVisibleLine"/> + <int Value="60" Name="CurrentLine"/> <wxArrayString Name="Bookmarks"/> <IntVector Name="CollapsedFolds"/> </TabInfo> diff --git a/CPP/BABS/BABS.mk b/CPP/BABS/BABS.mk index cbeb34b..7fcbd32 100644 --- a/CPP/BABS/BABS.mk +++ b/CPP/BABS/BABS.mk @@ -14,7 +14,7 @@ CurrentFileName := CurrentFilePath := CurrentFileFullPath := User :=Kamen -Date :=26/06/20 +Date :=27/06/20 CodeLitePath :=/home/kamen/.codelite LinkerName :=/usr/bin/g++ SharedObjectLinkerName :=/usr/bin/g++ -shared -fPIC diff --git a/CPP/BABS/BankAccount.cpp b/CPP/BABS/BankAccount.cpp index 180f56c..ea02d87 100644 --- a/CPP/BABS/BankAccount.cpp +++ b/CPP/BABS/BankAccount.cpp @@ -14,6 +14,7 @@ BankAccount::BankAccount(int initialDeposit) { balance = initialDeposit; } + int BankAccount::getId() { return id; } @@ -22,6 +23,11 @@ int BankAccount::getBalance() { return balance; } +bool BankAccount::getCloseStatus() { + return closed; +} + + void BankAccount::deposit(int amount) { balance += amount; } @@ -35,9 +41,13 @@ int BankAccount::withdraw(int amount) { } std::string BankAccount::toString() { - return "ID: " + std::to_string(id) + " Balance: " + std::to_string(balance); + return "ID: " + std::to_string(id) + " Balance: " + std::to_string(balance) + ((closed)?" CLOSED":""); } void BankAccount::close() { closed = true; +} + +void BankAccount::reopen() { + closed = false; }
\ No newline at end of file diff --git a/CPP/BABS/BankAccount.h b/CPP/BABS/BankAccount.h index 7e85b47..fbf808f 100644 --- a/CPP/BABS/BankAccount.h +++ b/CPP/BABS/BankAccount.h @@ -8,12 +8,16 @@ class BankAccount { public: BankAccount(); BankAccount(int); + int getId(); int getBalance(); + bool getCloseStatus(); + void deposit(int); int withdraw(int); std::string toString(); void close(); + void reopen(); }; #endif
\ No newline at end of file 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 diff --git a/CPP/BABS/main.cpp b/CPP/BABS/main.cpp index a9ff61e..717e0dd 100644 --- a/CPP/BABS/main.cpp +++ b/CPP/BABS/main.cpp @@ -14,7 +14,7 @@ int main() char inValue; cin >> inValue; - if (inValue == 'e' || inValue == 'E') { + if (inValue == 'e' || inValue == 'E' || inValue == '0') { return 0; } diff --git a/CPP/build-Debug/BABS/BankAccount.cpp.o b/CPP/build-Debug/BABS/BankAccount.cpp.o Binary files differindex 3c3b01a..17b532d 100644 --- a/CPP/build-Debug/BABS/BankAccount.cpp.o +++ b/CPP/build-Debug/BABS/BankAccount.cpp.o diff --git a/CPP/build-Debug/BABS/BankSystem.cpp.o b/CPP/build-Debug/BABS/BankSystem.cpp.o Binary files differindex 9a7dc03..8b097da 100644 --- a/CPP/build-Debug/BABS/BankSystem.cpp.o +++ b/CPP/build-Debug/BABS/BankSystem.cpp.o diff --git a/CPP/build-Debug/BABS/main.cpp.o b/CPP/build-Debug/BABS/main.cpp.o Binary files differindex 76c6cc8..cb8fbed 100644 --- a/CPP/build-Debug/BABS/main.cpp.o +++ b/CPP/build-Debug/BABS/main.cpp.o diff --git a/CPP/build-Debug/bin/BABS b/CPP/build-Debug/bin/BABS Binary files differindex 4fdf7ba..15c0a8b 100755 --- a/CPP/build-Debug/bin/BABS +++ b/CPP/build-Debug/bin/BABS |
