-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMain.cpp
90 lines (78 loc) · 2.16 KB
/
Main.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
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
// Program Information ////////////////////////////////////////////////////////
/**
* @file Main.cpp
*
* @brief Main driver for CPE400 Project Simulator
* Project 2: Using an energy‐constrained relay network cluster to
* transmit disaster area information to Command and Control Center
*
* @details Contains struct definitions, function definitions and main function
*
* @version 1.5
* Newest Addition: printMap function
*
* @Note None
*/
// Header files ///////////////////////////////////////////////////////////////
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <vector>
#include "simulator.cpp"
using namespace std;
// Begin main /////////////////////////////////////////////////////////////////
int main()
{
Drone* fleet;
vector<Disaster> disasterSet;
Disaster dis;
int disCount = 0;
int choice = 1;
bool relayCreated;
srand(time(NULL));
generateFleet( fleet );
while( choice != 0 )
{
if( choice == 1 )
{
makeDisaster( dis, disCount );
relayCreated = generateRelay( dis, fleet );
if( relayCreated )
{
disCount++;
disasterSet.push_back(dis);
cout << endl << "Relay network successfully established" << endl;
}
else
{
cout << endl
<< "Failed to generate relay network: not enough drones available"
<< endl << endl;
}
}
else if( choice == 2 )
{
displayRelay( fleet, disCount );
}
else if( choice == 3 )
{
simulateTime( fleet );
}
else if( choice == 4 )
{
if( !sendPacket( fleet ) )
{
cout << endl
<< "Unable to connect to fleet from given coordinates" << endl;
}
}
else if( choice == 5 )
{
printMap( fleet, disasterSet );
}
choice = getUserChoice();
}
delete[] fleet;
fleet = NULL;
return 0;
}