Created Bank.h and Bank.cpp to be used as the Bank Class of the game.

This commit is contained in:
Gustavo Henrique Santos Souza de Miranda 2024-09-27 10:50:20 -03:00
parent 09810d6449
commit a4993b02bc
2 changed files with 50 additions and 0 deletions

28
src/Bank.cpp Normal file
View File

@ -0,0 +1,28 @@
//
// Created by gustavomiranda on 27/09/24.
//
#include <cmath>
#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));
}

22
src/include/Bank.h Normal file
View File

@ -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