-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFireevacuation.cpp
More file actions
135 lines (113 loc) · 3.06 KB
/
Copy pathFireevacuation.cpp
File metadata and controls
135 lines (113 loc) · 3.06 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
#include <iostream>
using namespace std;
void bringEssentials() {
cout << "Bring wallet, keys, phone, wet towels.\n";
}
void contactFireDept() {
cout << "Contacting fire department...\n";
}
void stepsToFollow() {
cout << "Do not open the door.\n";
cout << "Seal all the cracks with wet towels.\n";
contactFireDept();
cout << "Wave at the windows to identify survivors.\n";
cout << "Wait for rescue.\n";
}
void pushAlarmTrigger() {
cout << "Push the fire alarm trigger to alert others!\n";
}
void findSafeRoomAndWait() {
cout << "Find and enter a safe room. Seal cracks and wait for rescue.\n";
stepsToFollow();
}
void goUp();
void reason2();
void goUp() {
cout << "Go upstairs and reach balcony.\n";
char reachedBalcony;
cout << "Did you reach the balcony? (y/n): ";
cin >> reachedBalcony;
if (reachedBalcony == 'y' || reachedBalcony == 'Y') {
cout << "Wait for help.\n";
} else {
reason2();
}
}
void reason2() {
char strongSmoke;
cout << "Is there strong smoke or fire? (y/n): ";
cin >> strongSmoke;
if (strongSmoke == 'y' || strongSmoke == 'Y') {
findSafeRoomAndWait();
} else {
goUp();
}
}
void reason1Flow();
void escapeFlow() {
cout << "Go downstairs and get out of the building.\n";
char escaped;
cout << "Did you successfully leave the building? (y/n): ";
cin >> escaped;
if (escaped == 'y' || escaped == 'Y') {
cout << "You have safely escaped the building! Stay safe.\n";
} else {
reason1Flow();
}
}
void reason1Flow() {
cout << "Reason-1: Cannot exit down due to fire/strong smoke.\n";
char strongSmoke;
cout << "Do you see strong smoke or fire while escaping? (y/n): ";
cin >> strongSmoke;
if (strongSmoke == 'y' || strongSmoke == 'Y') {
goUp();
} else {
escapeFlow();
}
}
void checkDoor() {
char input;
cout << "Is the door hot or is strong smoke present? (y/n): ";
cin >> input;
if (input == 'y' || input == 'Y') {
stepsToFollow();
} else {
escapeFlow();
}
}
void detectorProcess() {
cout << "Smoke detector detects smoke and triggers alarm.\n";
bringEssentials();
checkDoor();
}
void foundByYouOrSomeone() {
char placeFire;
cout << "Is the place of fire IN the building? (y/n): ";
cin >> placeFire;
if (placeFire == 'n' || placeFire == 'N') {
contactFireDept();
return;
} else if (placeFire == 'y' || placeFire == 'Y') {
bringEssentials();
pushAlarmTrigger();
checkDoor();
} else {
cout << "Invalid input.\n";
}
}
int main() {
cout << "*** FIRE EVACUATION PLAN ***\n";
cout << "How was the fire detected?\n";
cout << "1. You see fire/smoke\n2. Someone sees fire/smoke\n3. Smoke detector\nChoose (1/2/3): ";
int method;
cin >> method;
if (method == 3) {
detectorProcess();
} else if (method == 1 || method == 2) {
foundByYouOrSomeone();
} else {
cout << "Invalid input.\n";
}
return 0;
}