-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWolves.cpp
More file actions
50 lines (43 loc) · 1.8 KB
/
Wolves.cpp
File metadata and controls
50 lines (43 loc) · 1.8 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
#include <Wolves.h>
//Wolf constructor
Wolf::Wolf(std::string name, std::string furColour, std::string className, std::string classChar)
:name(name), furColour(furColour), className(className), classChar(classChar){
if (className == "WOLF")
std::cout<<"A "<<furColour<<" coloured "<<className<<" named "<<name<<" has come to wreak havoc!"<<std::endl;
}
//Makes wolf howl
void Wolf::Howl(){
std::cout<<name<<" the "<<className<<": "<<"ARROOOOOOOO!"<<std::endl;
}
//Makes wolf growl
void Wolf::Growl(){
std::cout<<name<<" the "<<className<<": "<<"GGRRRRRRRRR!"<<std::endl;
}
//Causes damage to citizens depending on their equity and a random number
bool Wolf::CauseDamage(Citizen &c, std::vector<Citizen*> &base, std::vector<Citizen*> &casualties){
if (c.GetBalance() <= 100){
std::cout << "The poor have no shelter and are devoured" << std::endl;
//Adds citizen to a casualties vector
casualties.push_back(&c);
//Erase citizen from citizens vector
base.erase(std::remove(base.begin(), base.end(), &c), base.end());
}
else if (c.GetBalance() <= 200 && (rand()%100 < 50))
{
std::cout << "The unfortunate few with nowhere to hide are devoured" << std::endl;
//Adds citizen to a casualties vector
casualties.push_back(&c);
//Erase citizen from citizens vector
base.erase(std::remove(base.begin(), base.end(), &c), base.end());
}
else
{
std::cout << "The sheltered and lucky ones live, but incur property damage" << std::endl;
//Take away the specified amount of money from citizen balance
c.LoseMoney(rand()%100);
}
std::cout << "And so fared " << c.GetPrefix()<< c.GetName() << c.GetSuffix() << std::endl;
}
//Wolf destructor
Wolf::~Wolf(){
}