-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnimais.cpp
More file actions
136 lines (97 loc) · 3.32 KB
/
Animais.cpp
File metadata and controls
136 lines (97 loc) · 3.32 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#include "Animais.h"
Animal::Animal(int nid, int nsaude, int ntmp_vida, int nfome, int npeso) : id(nid),
saude(nsaude),
tmp_vida(ntmp_vida),
fome(nfome),
peso(npeso)
{
instantes = 0;
IDMae = -1;
}
// char Animal::getLetra() const {};
// int Animal::mover(int fome) const {};
int Animal::getID() { return id; }
void Animal::setID(int n) { id = n; }
void Animal::setIDMae(int n) { IDMae = n; }
int Animal::getSaude() { return saude; }
void Animal::setSaude(int n) { saude = n; }
int Animal::getTmp_Vida() { return tmp_vida; }
void Animal::setTmp_Vida() { tmp_vida--; }
int Animal::getFome() { return fome; }
void Animal::setFome() { fome++; }
void Animal::setFome2(int n) { fome = fome - n; }
int Animal::getPeso() { return peso; }
void Animal::setPeso(int n) { peso = n; }
int Animal::getLinha() { return linha; }
void Animal::setLinha(int n) { linha = n; }
int Animal::getColuna() { return coluna; }
void Animal::setColuna(int n) { coluna = n; }
int Animal::getInstantes() { return instantes; }
void Animal::setInstantes() { instantes++; }
void Animal::setInstantes2(int n) { instantes = n; }
void Animal::MostraVector3()
{
for (auto it : alimentosAnim)
{
cout << "TipoAlimento: " << it->getLetra() << endl
<< "ID: " << it->getID() << endl
<< "ValorNutritivo: " << it->getValor_Nut() << endl
<< "Toxicidade: " << it->getToxicidade() << endl
<< "Tmp_Vida: " << it->getTmp_Vida() << endl
<< endl;
}
};
// ---- Coelho ----
char Coelho::getLetra() const { return 'C'; }
int Coelho::mover(int fome) const
{
if (fome > 10 && fome <= 20)
{
return 1 + (rand() % 3);
}
else if (fome > 20)
{
return 1 + (rand() % 4);
}
else
{
return 1 + (rand() % 2);
}
}
Coelho::Coelho(int nid, int nsaude, int ntmp_vida, int nfome, int npeso) : Animal(nid, nsaude, ntmp_vida, nfome, npeso) {}
// ---- Ovelha ----
char Ovelha::getLetra() const { return 'O'; }
int Ovelha::mover(int fome) const
{
if (fome > 15)
{
return 1 + (rand() % 2);
}
else
{
return 1;
}
}
Ovelha::Ovelha(int nid, int nsaude, int ntmp_vida, int nfome, int npeso) : Animal(nid, nsaude, ntmp_vida, nfome, npeso) {}
// ---- Lobo ----
char Lobo::getLetra() const { return 'L'; }
int Lobo::mover(int fome) const
{
if (fome > 15)
{
return 2;
}
else
{
return 1;
}
}
Lobo::Lobo(int nid, int nsaude, int ntmp_vida, int nfome, int npeso) : Animal(nid, nsaude, ntmp_vida, nfome, npeso) {}
// ---- Canguru ----
char Canguru::getLetra() const { return 'G'; }
int Canguru::mover(int fome) const { return 1; }
Canguru::Canguru(int nid, int nsaude, int ntmp_vida, int nfome, int npeso) : Animal(nid, nsaude, ntmp_vida, nfome, npeso) {}
// ---- Animal Misterio ----
char AnimMist::getLetra() const { return 'M'; }
int AnimMist::mover(int fome) const{ return 2 + (rand() % 3);}
AnimMist::AnimMist(int nid, int nsaude, int ntmp_vida, int nfome, int npeso) : Animal(nid, nsaude, ntmp_vida, nfome, npeso) {}