diff --git a/src/Bank.cpp b/src/Bank.cpp new file mode 100644 index 0000000..ea5d8c2 --- /dev/null +++ b/src/Bank.cpp @@ -0,0 +1,28 @@ +// +// Created by gustavomiranda on 27/09/24. +// +#include +#include "Bank.h" + +Bank::Bank(double taxvalue) { + setTax(taxvalue); + money = 0; +} + +void Bank::depositMoney(int value) { + money += value; +} + +void Bank::withdrawMoney(int value) { + if (money >= value){ + money -= value; + } +} + +int Bank::getMoney() { + return money; +} + +void Bank::updateMoney() { + money = std::round(money * (1+tax)); +} \ No newline at end of file diff --git a/src/include/Bank.h b/src/include/Bank.h new file mode 100644 index 0000000..6a3b15c --- /dev/null +++ b/src/include/Bank.h @@ -0,0 +1,22 @@ +// +// Created by gustavomiranda on 27/09/24. +// + +#ifndef DRUGWARS_BANK_H +#define DRUGWARS_BANK_H + +class Bank{ +private: + int money; + double tax; + void setTax(double value); +public: + Bank(double taxvalue); + void depositMoney(int value); + void withdrawMoney(int value); + int getMoney(); + void updateMoney(); + +}; + +#endif //DRUGWARS_BANK_H