PPL Assignment
IRM2015006
miserboy.cpp
Go to the documentation of this file.
1 #include "miserboy.h"
2 
3 MiserBoy::MiserBoy(std::string name, int attr, int intel, int budget, int min_attr_req)
4 {
5  this->name = name;
6  this->intel = intel;
7  this->attr = attr;
8  this->budget = budget;
9  this->min_attr_req = min_attr_req;
10  this->committed = false;
11  this->happiness = 0;
12  this->girlfriend = NULL;
13  this->gifts = NULL;
14 }
15 
17 {
18  float happiness = 0;
19  if (!committed || !girlfriend || !gifts)
20  return -1;
21 
22  happiness = budget;
23  for (auto it = gifts->begin(); it != gifts->end(); it++) {
24  happiness -= it->price;
25  }
26  this->happiness = happiness;
27  return happiness;
28 }
29 
31 {
32  return nature;
33 }
bool committed
Definition: boy.h:32
int attr
Definition: boy.h:25
std::vector< Gift > * gifts
Definition: boy.h:33
float happiness
Definition: boy.h:29
MiserBoy(std::string name, int attr, int intel, int budget, int min_attr_req)
Definition: miserboy.cpp:3
int min_attr_req
Definition: boy.h:28
int budget
Definition: boy.h:27
int intel
Definition: boy.h:26
float getHappiness() override
Definition: miserboy.cpp:16
std::string name
Definition: boy.h:24
BoyNature getNature() override
Definition: miserboy.cpp:30
Girl * girlfriend
Definition: boy.h:30
static const BoyNature nature
Definition: miserboy.h:12
BoyNature
Definition: boy_type.h:5