Skip to content
Snippets Groups Projects
Commit c949f120 authored by fuzzy_bunny's avatar fuzzy_bunny
Browse files

corrected the way to get getBehaviourName()

parent 7f83f51c
No related branches found
No related tags found
1 merge request!19Master
......@@ -16,7 +16,7 @@ int main(){
int windowHeight = 800; //480
int delay = 30;
int startingNbPets = 70;
map<string, float> animalsDistribution = {{KamikazeBehaviour::getBehaviourName(), 10}, {FearfulBehaviour::getBehaviourName(), 30}, {GregariousBehaviour::getBehaviourName(), 40}, {"multiple", 20}};
map<string, float> animalsDistribution = {{KamikazeBehaviour::getBehaviourInstance()->getBehaviourName(), 10}, {FearfulBehaviour::getBehaviourInstance()->getBehaviourName(), 30}, {GregariousBehaviour::getBehaviourInstance()->getBehaviourName(), 40}, {"multiple", 20}};
Aquarium ecosystem(windowWidth, windowHeight, delay, startingNbPets, animalsDistribution);
ecosystem.run();
......
......@@ -248,17 +248,17 @@ void Animal::setColor(const T c[3]) {
void Animal::setBehaviour(string behaviourName) {
if (behaviourName == GregariousBehaviour::getBehaviourName()) {
if (behaviourName == GregariousBehaviour::getBehaviourInstance()->getBehaviourName()) {
this->setColor(GregariousBehaviour::getColor());
this->behaviour = GregariousBehaviour::getBehaviourInstance();
}
else {
if (behaviourName == FearfulBehaviour::getBehaviourName()) {
if (behaviourName == FearfulBehaviour::getBehaviourInstance()->getBehaviourName()) {
this->setColor(FearfulBehaviour::getColor());
this->behaviour = FearfulBehaviour::getBehaviourInstance();
}
else {
if (behaviourName == KamikazeBehaviour::getBehaviourName()) {
if (behaviourName == KamikazeBehaviour::getBehaviourInstance()->getBehaviourName()) {
this->setColor(KamikazeBehaviour::getColor());
this->behaviour = KamikazeBehaviour::getBehaviourInstance();
}
......
......@@ -12,7 +12,7 @@ class BehaviourStrategy
public:
virtual ~BehaviourStrategy(){};
static std::string getBehaviourName(){return " ";}
virtual std::string getBehaviourName() = 0;
virtual std::vector<Animal *> nearestNeighbors(Animal* pet, Environment& myEnvironment) = 0;
virtual void move(int xLim, int yLim, Animal* pet, Environment& myEnvironment) = 0;
......
......@@ -19,7 +19,7 @@ public:
static const T* getColor();
static FearfulBehaviour* getBehaviourInstance();
static void getRidOfInstance();
static std::string getBehaviourName();
std::string getBehaviourName() override;
std::vector<Animal *> nearestNeighbors(Animal* pet, Environment& myEnvironment) override;
void move(int xLim, int yLim, Animal* pet, Environment& myEnvironment) override;
......
......@@ -24,7 +24,7 @@ class GregariousBehaviour: public BehaviourStrategy{
static GregariousBehaviour* getBehaviourInstance();
static void getRidOfInstance();
static std::string getBehaviourName();
std::string getBehaviourName() override;
static const T* getColor();
std::vector<Animal *> nearestNeighbors(Animal* pet, Environment& myEnvironment) override;
......
......@@ -23,7 +23,7 @@ class KamikazeBehaviour: public BehaviourStrategy{
static KamikazeBehaviour* getBehaviourInstance();
static void getRidOfInstance();
static std::string getBehaviourName();
std::string getBehaviourName() override;
static const T* getColor() ;
std::vector<Animal *> nearestNeighbors(Animal* pet, Environment& myEnvironment) override;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment