-
Notifications
You must be signed in to change notification settings - Fork 0
/
Animal.cpp
38 lines (30 loc) · 813 Bytes
/
Animal.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
35
36
37
38
#include "Animal.h"
#include "RandomG.h"
#include<iosteam>
using namespace std;
Animal::Animal()
{ this->name = " ";
this->energy = 0;
this->power = 0;
this->size = 0;
this->weight = 0;
point = new Point2D();
this->state = State.Unknown;
}
Animal::Animal(string name,double energy,double power,double size,double weight,Point2D* point,State state) : Entity(name, energy, power, size, weight, point, state)
{
}
void Animal::Eat() {
RandomG food;
this->weight += food.RandomNumber();
this->setState(Eating);
}
void Animal::Sleep(){
setEnergy(getPower() + 10);
this->setState(Sleeping);
}
void Animal::SearchingForFood(){
RandomG food;
this->power -= food.RandomNumber();
this->setState(SearchingForFood);
}