-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathRegistration.cpp
More file actions
385 lines (380 loc) · 10.1 KB
/
Registration.cpp
File metadata and controls
385 lines (380 loc) · 10.1 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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
#include <iostream>
#include<stdlib.h>
#include<conio.h>
using namespace std;
#include <fstream>
class vaccine_dose_data
{
private:
char candidate_name[30]; //30
long int aadhar_num; //4
int birth_date;
int birth_month;
int birth_year;
int today_date;
int today_month;
int today_year;
int candidate_age;
int anti_body_entry; //6
int vaccine_which_entry;
int vaccine_which_entry_2;
public:
void get_details()
{
cout << "\nENTER NAME(as written on aadhar card) : ";
fflush(stdin);
cin.get(candidate_name, 30);
aadhar_num = 0;
cout << "ENTER AADHAR CARD NUMBER : ";
cin >> aadhar_num;
cout << "\nENTER TODAY'S DATE : \n";
cout << "DAY : ";
cin >> today_date;
cout << "MONTH : ";
cin >> today_month;
cout << "YEAR : ";
cin >> today_year;
cout << "\nENTER BIRTH DETAILS : \n\n";
cout << "DAY : ";
cin >> birth_date;
cout << "MONTH : ";
cin >> birth_month;
cout << "YEAR : ";
cin >> birth_year;
}
int age_verify()
{
if ((today_year - birth_year) == 18)
{
if (today_month > birth_month)
{
if (today_date > birth_date)
{
return 1;
}
else
{
return 2;
}
}
else
{
return 2;
}
}
if (today_year - birth_year > 18)
{
return 1;
}
else
{
return 2;
}
}
void show_details()
{
cout << "NAME : " << candidate_name << endl;
cout << "AADHAR NUMBER : " << aadhar_num << endl;
cout << "BIRTH DATE : " << birth_date << "/" << birth_month << "/" << birth_year << endl;
cout << "ANTI BODY STATUS : ";
if (anti_body_entry == 1)
{
cout << "YES\n";
}
if (anti_body_entry == 2)
{
cout << "NO\n";
}
if (vaccine_which_entry == 1)
{
cout << "VACCINE DOSE 1 TYPE : COVAXIN\n";
}
if (vaccine_which_entry == 2)
{
cout << "VACCINE DOSE 1 TYPE : COVISHIELD\n";
}
if (vaccine_which_entry == 3)
{
cout << "VACCINE DOSE 1 TYPE : SPUTNIK\n";
}
}
void anti_body()
{
cout << "\nHISTORY OF COVID : \n\n";
cout << "ENTER 1 : IF YOU WERE CORONA POSITIVE\nENTER 2 : IF YOU WERE NOT CORONA POSITIVE\n\n";
cin >> anti_body_entry;
}
void which_vaccine()
{
cout << "\nENTER 1 : COVAXIN\nENTER 2 : COVISHIELD\nENTER 3 : SPUTNIK\n\n";
cin >> vaccine_which_entry;
cout << "\n\nCONGRATULATIONS YOU HAVE BEEN VACCINATED WITH 1st DOSE\n\n";
}
int check_sputnik()
{
if (vaccine_which_entry == 3)
{
cout << "\n\nSPUTNIK only requires one dose\n\n";
return 3;
}
else
return 1;
}
void which_vaccine_2()
{
cout << "\nCHOOSE VACCINE FOR 2nd DOSE : \n\n";
cout << "\n\nENTER 1 : COVAXIN ";
if (vaccine_which_entry == 1)
{
cout << "(1st dose)\n";
}
else
{
cout << "\n";
}
cout << "ENTER 2 : COVISHIELD";
if (vaccine_which_entry == 2)
{
cout << "(1st dose)\n";
}
else
{
cout << "\n";
}
cin >> vaccine_which_entry_2;
}
void final_message()
{
cout << "NAME : " << candidate_name << endl;
cout << "AADHAR NUMBER : " << aadhar_num << endl;
cout << "BIRTH DATE : " << birth_date << "/" << birth_month << "/" << birth_year << endl;
cout << "ANTI BODY STATUS : ";
if (anti_body_entry == 1)
{
cout << "YES\n";
}
if (anti_body_entry == 2)
{
cout << "NO\n";
}
if (vaccine_which_entry == 1)
{
cout << "VACCINE DOSE 1 TYPE : COVAXIN\n";
}
if (vaccine_which_entry == 2)
{
cout << "VACCINE DOSE 1 TYPE : COVISHIELD\n";
}
if (vaccine_which_entry == 3)
{
cout << "VACCINE DOSE TYPE : SPUTNIK\n";
}
if (vaccine_which_entry_2 == 1)
{
cout << "VACCINE DOSE 2 TYPE : COVAXIN\n";
}
if (vaccine_which_entry_2 == 2)
{
cout << "VACCINE DOSE 2 TYPE : COVISHIELD\n";
}
}
int search_candidate(long int class_aadhar_num)
{
if (class_aadhar_num == aadhar_num)
{
return 1;
}
else
{
return 2;
}
}
int search_candidate_if_first_dose(vaccine_dose_data obz)
{
if (obz.aadhar_num == aadhar_num)
{
return 2;
}
else
{
return 1;
}
}
int if_both_vaccine_done()
{
if (vaccine_which_entry_2 == 1 || vaccine_which_entry_2 == 2)
{
return 4;
}
else
return 1;
}
int aadhar_dose_1()
{
if (aadhar_num != 0)
{
return 1;
}
else
{
return 2;
}
}
};
int main()
{
int what_about;
vaccine_dose_data ob1;
vaccine_dose_data ob2[100];
int vaccine_num;
int aadhar_dose_d;
int check_d;
static int number_of_first;
long int main_aadhar_num;
while (1)
{
fstream ob("myfile_2.txt", ios::in | ios::out | ios::ate);
cout << "\n\nENTER 1 : FIRST DOSE VACCINE\nENTER 2 : SECOND DOSE VACCINE\nENTER 3 : DISPLAY CERTIFICATE\nENTER 4 : EXIT\n\n";
fflush(stdin);
what_about = 0;
cin >> vaccine_num;
switch (vaccine_num)
{
case 1:
{
int first_vaccine_d;
int age_verify_d;
int closure;
int d_break;
ob1.get_details();
age_verify_d = ob1.age_verify();
if (age_verify_d == 2)
{
cout << "\n\n--VACCINATION DENIED AS THE CANDIDATE IS UNDER 18--\n\n";
ob.close();
break;
}
int end = ob.tellg();
int size = sizeof(ob1);
int qty = end / size;
ob.seekg(0);
for (int i = 0; i < qty; i++)
{
ob.read((char *)&ob2[i], sizeof(ob2[i]));
first_vaccine_d = ob2[i].search_candidate_if_first_dose(ob1);
if (first_vaccine_d == 2)
{
cout << "\n\n--CANDIDATE HAS ALREADY BEEN VACCINATED WITH DOSE - 1--\n\n";
d_break = 3;
ob.close();
break;
}
}
if (d_break != 3)
{
ob1.anti_body();
ob1.which_vaccine();
ob.write((char *)&ob1, sizeof(ob1));
ob.close();
break;
}
ob.close();
break;
}
case 2:
{
int entry_3;
cout << "ENTER AADHAR CARD NUMBER : ";
cin >> main_aadhar_num;
int j_final;
int end = ob.tellg();
int size = sizeof(ob1);
int qty = end / size;
ob.seekg(0);
for (int j = 0; j < qty; j++)
{
ob.read((char *)&ob2[j], sizeof(ob2[j]));
int return_d = ob2[j].search_candidate(main_aadhar_num);
if (return_d == 1)
{
int if_both_d = ob2[j].if_both_vaccine_done();
if (if_both_d == 4)
{
what_about = 10;
cout << "BOTH VACCINATIONS HAVE BEEN DONE\n";
ob.close();
break;
break;
}
break;
}
}
if (what_about == 10)
{
ob.close();
break;
}
ob.seekg(0);
for (int j = 0; j < qty; j++)
{
ob.read((char *)&ob2[j], sizeof(ob2[j]));
int return_d = ob2[j].search_candidate(main_aadhar_num);
if (return_d == 1)
{
j_final = j;
cout << "\n\nSHOWING DETAILS : \n\n";
ob2[j].show_details();
check_d = ob2[j].check_sputnik();
break;
}
}
if (check_d == 3)
{
ob.close();
break;
}
ob2[j_final].which_vaccine_2();
ob.seekp(size * (j_final));
ob.write((char *)&ob2[j_final], sizeof(ob2[j_final]));
cout << "YOUR VACCINATION IS COMPLETE \n\nCERTIFICATE : \n\n";
ob2[j_final].final_message();
ob.close();
break;
}
case 3:
{
int count = 0;
cout << "ENTER AADHAR CARD NUMBER : ";
cin >> main_aadhar_num;
int end = ob.tellg();
int size = sizeof(ob1);
int qty = end / size;
ob.seekg(0);
for (int j = 0; j < qty; j++)
{
ob.read((char *)&ob2[j], sizeof(ob2[j]));
int return_d = ob2[j].search_candidate(main_aadhar_num);
if (return_d == 1)
{
cout << "\n\nSHOWING CERTIFICATE : \n\n";
ob2[j].final_message();
break;
}
count++;
}
if (count == qty)
{
cout << "\n\nCANDIDATE HAS NOT GOT BOTH DOSE-1 AND DOSE-2\n\n";
}
ob.close();
break;
}
case 4:
ob.close();
exit(0);
default:
cout << "\n\n---WRONG CHOICE---\n\n";
}
}
return 0;
}