-
Notifications
You must be signed in to change notification settings - Fork 0
/
Plant.cpp
34 lines (26 loc) · 824 Bytes
/
Plant.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
//
// Created by Dominic Rutkowski on 2019-04-10.
//
#include "Plant.hpp"
namespace cs3210 {
Plant::Plant(const std::string& symbol, const unsigned int maxEnergy, const unsigned int regrowthCoefficient):
Organism(symbol, maxEnergy, maxEnergy), regrowthCoefficient{regrowthCoefficient}, iterationsUntilGrowth{0} {}
void Plant::iterate() {
if (iterationsUntilGrowth > 0) {
--iterationsUntilGrowth;
}
}
unsigned int Plant::consume() {
iterationsUntilGrowth = regrowthCoefficient;
return maxEnergy;
}
unsigned int Plant::getIterationsUntilGrowth() const {
return iterationsUntilGrowth;
}
std::string Plant::toString() const {
if (iterationsUntilGrowth <= 0) {
return symbol;
}
return " ";
}
}