-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
64 lines (52 loc) · 1.75 KB
/
Copy pathmain.cpp
File metadata and controls
64 lines (52 loc) · 1.75 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
#include <iostream>
#include <array>
#include "Sun.h"
#include "Resources/Grass.h"
#include "Animals/Cow.h"
#include "Resources/Rabbit_Hole.h"
#include "Animals/Rabbit.h"
#include "Animals/Wolf.h"
#include "Utils/Graphics.h"
static const int NUMBER_OF_GRASS = 15;
static const int NUMBER_OF_COWS = 10;
static const int NUMBER_OF_RABBITS = 10;
static const int NUMBER_OF_RABBIT_HOLES = 2;
static const int NUMBER_OF_WOLVES = 10;
int main() {
Pond *pond = new Pond(5);
Meadow meadow(pond);
Sun *sun = new Sun(meadow);
std::vector<Grass*> grass;
for (int i = 0; i < NUMBER_OF_GRASS; i++) {
grass.push_back(new Grass(i, *sun, meadow));
}
std::vector<Rabbit_Hole*> rabbit_holes;
for (int i = 0; i < NUMBER_OF_RABBIT_HOLES; i++) {
rabbit_holes.push_back(new Rabbit_Hole(3));
}
std::vector<Cow*> cows;
for (int i = 0; i < NUMBER_OF_COWS; ++i) {
cows.push_back(new Cow(i, grass, meadow));
}
std::vector<Rabbit*> rabbits;
for (int i = 0; i < NUMBER_OF_RABBITS; ++i) {
rabbits.push_back(new Rabbit(i, grass, meadow, rabbit_holes));
}
std::vector<Wolf*> wolves;
for (int i = 0; i < NUMBER_OF_WOLVES; ++i) {
wolves.push_back(new Wolf(i, rabbits, meadow, *sun));
}
std::this_thread::sleep_for(std::chrono::seconds(1));
meadow.ready = true;
meadow.synchronization.setSleep(false);
meadow.synchronization.notify_all();
auto *graphics = new Graphics(cows, rabbits, rabbit_holes, wolves, meadow, *sun);
graphics->init();
std::this_thread::sleep_for(std::chrono::seconds(30));
meadow.ready = false;
Utils::thread_safe_cout("===== FINISHING =====");
Utils::thread_safe_cout("Animals are going on holiday!");
getch();
endwin();
return 0;
}