PPL Assignment
IRM2015006
choosygirl.cpp
Go to the documentation of this file.
1 #include "choosygirl.h"
2 
3 #include <cmath>
4 
5 ChoosyGirl::ChoosyGirl(std::string name, int attr, int intel, int budget, BoyType boy_type)
6 {
7  this->name = name;
8  this->attr = attr;
9  this->intel = intel;
10  this->budget = budget;
11  this->boy_type = boy_type;
12  this->committed = false;
13  this->boyfriend = NULL;
14  this->gifts = NULL;
15  this->happiness = 0;
16 }
17 
19 {
20  float happiness = 0;
21  if (!this->gifts)
22  return -1;
23 
24  for (std::vector<Gift> ::iterator it = gifts->begin();
25  it != gifts->end();
26  it++) {
27 
28  happiness += log10(it->price);
29  if (it->type == luxury)
30  happiness += it->value*2;
31  }
32  this->happiness = happiness;
33  return this->happiness;
34 }
35 
37 {
38  return nature;
39 }
float getHappiness() override
Definition: choosygirl.cpp:18
static const GirlNature nature
Definition: choosygirl.h:12
BoyType
Definition: girl_type.h:12
GirlNature getNature() override
Definition: choosygirl.cpp:36
std::string name
Definition: girl.h:24
float happiness
Definition: girl.h:28
Boy * boyfriend
Definition: girl.h:30
ChoosyGirl(std::string name, int attr, int intel, int budget, BoyType boy_type)
Definition: choosygirl.cpp:5
Definition: gift.h:9
std::vector< Gift > * gifts
Definition: girl.h:32
BoyType boy_type
Definition: girl.h:29
GirlNature
Definition: girl_type.h:5
int attr
Definition: girl.h:25
int budget
Definition: girl.h:27
bool committed
Definition: girl.h:23
int intel
Definition: girl.h:26