diff options
| author | Syndamia <kamen.d.mladenov@protonmail.com> | 2020-10-24 15:25:54 +0300 |
|---|---|---|
| committer | Syndamia <kamen.d.mladenov@protonmail.com> | 2020-10-24 15:25:54 +0300 |
| commit | be891b06d065504be51d094503c654377ebc22d7 (patch) | |
| tree | 9ab8742b063a19c713a5ba923aa96605b4b752fa /C++/BABS/BankAccount.cpp | |
| parent | 8f5cbebb028d9f9fba367019de0a45b43ab7ed4d (diff) | |
| download | Self-learning-be891b06d065504be51d094503c654377ebc22d7.tar Self-learning-be891b06d065504be51d094503c654377ebc22d7.tar.gz Self-learning-be891b06d065504be51d094503c654377ebc22d7.zip | |
Renamed C++ folder to C++ (from CPP)
Diffstat (limited to 'C++/BABS/BankAccount.cpp')
| -rw-r--r-- | C++/BABS/BankAccount.cpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/C++/BABS/BankAccount.cpp b/C++/BABS/BankAccount.cpp new file mode 100644 index 0000000..ea02d87 --- /dev/null +++ b/C++/BABS/BankAccount.cpp @@ -0,0 +1,53 @@ +#include <string> + +#include "BankAccount.h" + +int currId = 0; + +BankAccount::BankAccount() { + id = currId++; + balance = 0; +} + +BankAccount::BankAccount(int initialDeposit) { + id = currId++; + balance = initialDeposit; +} + + +int BankAccount::getId() { + return id; +} + +int BankAccount::getBalance() { + return balance; +} + +bool BankAccount::getCloseStatus() { + return closed; +} + + +void BankAccount::deposit(int amount) { + balance += amount; +} + +int BankAccount::withdraw(int amount) { + if (amount > balance) { + return -1; + } + balance -= amount; + return amount; +} + +std::string BankAccount::toString() { + 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 |
