-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnimal.cpp
More file actions
46 lines (41 loc) · 688 Bytes
/
Copy pathAnimal.cpp
File metadata and controls
46 lines (41 loc) · 688 Bytes
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
39
40
41
42
43
44
45
46
#include <stdlib.h>
#include <iostream>
#include "Animal.h"
#include "Field.h"
using namespace std;
unsigned int Animal::GetX()const
{
return x;
};
unsigned int Animal::GetY()const
{
return y;
};
void Animal::SetX(unsigned int newX)
{
x = newX;
return;
};
void Animal::SetY(unsigned int newY)
{
y = newY;
return;
};
/*ïðîâåðèì êëåòêè âîêðóã, íàõîäèì ñâîáîäíóþ ðàíäîìíî, ïåðåìåùàåìñÿ íà íå¸*/
void Animal::move(Field& userMap, const vector<bool>& poz)
{
int count = 0;
unsigned int newX = GetX(), newY = GetY();
if (userMap.FindFreeCell(newX, newY, *this, poz) == false)
{
newX = GetX();
newY = GetY();
return;
}
else
{
SetX(newX);
SetY(newY);
return;
}
};