forked from ivogeorg/ucd-csci2312-pa4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Advantage.cpp
42 lines (33 loc) · 962 Bytes
/
Advantage.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//
// Created by Mario on 4/11/2016.
//
#include "Advantage.h"
#include "sstream"
namespace Gaming {
const char Advantage::ADVANTAGE_ID = 'D';
const double Advantage::ADVANTAGE_MULT_FACTOR = 2.0;
Advantage::Advantage(const Game &g, const Position &p, double capacity) : Resource(g, p, capacity * ADVANTAGE_MULT_FACTOR) {
__capacity = capacity * ADVANTAGE_MULT_FACTOR;
}
Advantage::~Advantage() {
}
void Advantage::print(std::ostream &os) const {
std::string str;
str = std::to_string(__id);
std::stringstream ss;
ss << ADVANTAGE_ID << str;
std::getline(ss, str);
for(int i = 0; i < str.length(); i++) {
os << str[i];
}
}
double Advantage::consume() {
double capacity = __capacity;
__capacity = -1;
finish();
return capacity;
}
double Advantage::getCapacity() const {
return __capacity;
}
}