Created the Player.cpp and Player.h that will be used as player class in the game.
This commit is contained in:
parent
9bd09b0483
commit
7887ee2678
|
|
@ -0,0 +1,33 @@
|
||||||
|
//
|
||||||
|
// Created by gustavomiranda on 27/09/24.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "Player.h"
|
||||||
|
|
||||||
|
|
||||||
|
int Player::getCurrentMoney() {
|
||||||
|
return money;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Player::incrementMoney(int value) {
|
||||||
|
money += value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Player::decrementMoney(int value) {
|
||||||
|
if(money >= value){
|
||||||
|
money -= value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Bag* Player::getInventory(){
|
||||||
|
return inventory;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player::Player(){
|
||||||
|
setMoney(2500);
|
||||||
|
inventory = new Bag(100);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Player::~Player() {
|
||||||
|
delete inventory;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
//
|
||||||
|
// Created by gustavomiranda on 27/09/24.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef DRUGWARS_PLAYER_H
|
||||||
|
#define DRUGWARS_PLAYER_H
|
||||||
|
|
||||||
|
|
||||||
|
#include "Bag.h"
|
||||||
|
|
||||||
|
class Player {
|
||||||
|
private:
|
||||||
|
int money;
|
||||||
|
Bag * inventory;
|
||||||
|
void setMoney(int value);
|
||||||
|
public:
|
||||||
|
Player();
|
||||||
|
~Player();
|
||||||
|
int getCurrentMoney();
|
||||||
|
void incrementMoney(int value);
|
||||||
|
void decrementMoney(int value);
|
||||||
|
Bag *getInventory();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif //DRUGWARS_PLAYER_H
|
||||||
Loading…
Reference in New Issue