PPL Assignment
IRM2015006
Main Page
Classes
Files
File List
File Members
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
16
float
MiserBoy::getHappiness
()
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
30
BoyNature
MiserBoy::getNature
()
31
{
32
return
nature
;
33
}
Boy::committed
bool committed
Definition:
boy.h:32
Boy::attr
int attr
Definition:
boy.h:25
Boy::gifts
std::vector< Gift > * gifts
Definition:
boy.h:33
Boy::happiness
float happiness
Definition:
boy.h:29
miserboy.h
MiserBoy::MiserBoy
MiserBoy(std::string name, int attr, int intel, int budget, int min_attr_req)
Definition:
miserboy.cpp:3
Boy::min_attr_req
int min_attr_req
Definition:
boy.h:28
Boy::budget
int budget
Definition:
boy.h:27
Boy::intel
int intel
Definition:
boy.h:26
MiserBoy::getHappiness
float getHappiness() override
Definition:
miserboy.cpp:16
Boy::name
std::string name
Definition:
boy.h:24
MiserBoy::getNature
BoyNature getNature() override
Definition:
miserboy.cpp:30
Boy::girlfriend
Girl * girlfriend
Definition:
boy.h:30
MiserBoy::nature
static const BoyNature nature
Definition:
miserboy.h:12
BoyNature
BoyNature
Definition:
boy_type.h:5
boys
miserboy.cpp
Generated by
1.8.11