Created Bank.h and Bank.cpp to be used as the Bank Class of the game.
This commit is contained in:
parent
09810d6449
commit
a4993b02bc
|
|
@ -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));
|
||||
}
|
||||
|
|
@ -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
|
||||
Loading…
Reference in New Issue