-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcriminal_record_system.cpp
More file actions
415 lines (378 loc) · 14 KB
/
criminal_record_system.cpp
File metadata and controls
415 lines (378 loc) · 14 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
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
#include <iostream>
#include <string>
using namespace std;
// Class for pre-registered criminals(inheritence)
class regcriminal {
protected: //Encapsulation
string Name[10];
int Age[10];
int Reg[10];
int Date[10];
int Month[10];
int Year[10];
string Crime[10];
string Penalty[10];
public:
int Totalcriminal = 10;
regcriminal() {
Name[0] = "qadeer"; Age[0] = 34; Reg[0] = 1; Date[0] = 2; Month[0] = 3; Year[0] = 2014; Crime[0] = "murder"; Penalty[0] ="life imprisonment";
Name[1] = "irfan"; Age[1] = 22; Reg[1] = 34; Date[1] = 4; Month[1] = 8; Year[1] = 2018; Crime[1] = "Robery"; Penalty[1] = "two year in prison";
Name[2] = "ateeq"; Age[2] = 18; Reg[2] = 44; Date[2] = 7; Month[2] = 4; Year[2] = 2004; Crime[2] = "drug offense"; Penalty[2] = "two lac ";
Name[3] = "saad"; Age[3] = 45; Reg[3] = 45; Date[3] = 5; Month[3] = 5; Year[3] = 2023; Crime[3] = "Fraud";Penalty[3] = "50 lac";
Name[4] = "hafeez"; Age[4] = 30; Reg[4] = 453; Date[4] = 30; Month[4] = 2; Year[4] = 2011; Crime[4] = "kidnapping"; Penalty[4]="1 year in prsion" ;
Name[5] = "adeel"; Age[5] = 28; Reg[5] = 437; Date[5] = 20; Month[5] = 3; Year[5] = 2024; Crime[5] = "vandalism"; Penalty[5] = "30 lac";
Name[6] = "daniyal"; Age[6] = 22; Reg[6] = 675; Date[6] = 16; Month[6] = 4; Year[6] = 2022; Crime[6] = "perjury"; Penalty[6] = "5 years in prison";
Name[7] = "haris"; Age[7] = 19; Reg[7] = 823; Date[7] = 19; Month[7] = 4; Year[7] = 2020; Crime[7] = "pickpocket"; Penalty[7] = "60 thousand";
Name[8] = "sajjad"; Age[8] = 50; Reg[8] = 987; Date[8] = 25; Month[8] = 10; Year[8] = 2005; Crime[8] = "robery"; Penalty[8] = "20 lacs";
Name[9] = "waleed"; Age[9] = 24; Reg[9] = 678; Date[9] = 8; Month[9] = 12; Year[9] = 2008; Crime[9] = "domestic violence"; Penalty[9] = "6 years in prison";
}
void virtual show(){
cout<<"details are"<<endl;
}
void virtual searched(){
cout<<"Searched data"<<endl;
}
void virtual changes(){
cout<<"Changed data"<<endl;
}
void virtual deleteRecords() {
cout<<"Delete records"<<endl;
}
};
class functions: public regcriminal {
public:
void show() {
cout << "Name\t\tAge\tReg no\tDate\tMonth\tYear\tCrime\t\tpenalty" << endl;
cout << "---------------------------------------------------------------------------" << endl;
for (int i = 0; i < Totalcriminal; i++) {
cout << Name[i] << "\t\t" << Age[i] << "\t" << Reg[i] << "\t" << Date[i] << "\t" << Month[i] << "\t" << Year[i] << "\t" << Crime[i] << "\t\t" << Penalty[i] << endl;
}
}
void searched() {
string n;
cout<<"enter name "<<endl;
cin.ignore();
getline(cin, n);
bool found = false;
for (int i = 0; i < Totalcriminal; i++) {
if (n == Name[i]) {
cout << "Criminal details are:" << endl;
cout << "Name: " << Name[i] << endl;
cout << "Age: " << Age[i] << endl;
cout << "Registration number: " << Reg[i] << endl;
cout << "Date: " << Date[i] << endl;
cout << "Month: " << Month[i] << endl;
cout << "Year: " << Year[i] << endl;
cout << "Crime: " << Crime[i] << endl;
cout << "Punishment: " << Penalty[i] << endl;
found = true;
break;
}
}
if (!found) {
cout << "No record found." << endl;
}
}
void changes() {
int regnu;
cout << "Enter registration number of criminal you want to change data of: ";
cin >> regnu;
bool found = false;
for (int i = 0; i < Totalcriminal; i++) {
if (regnu == Reg[i]) {
cout << "Previous data:" << endl;
cout << "Name: " << Name[i] << endl;
cout << "Age: " << Age[i] << endl;
cout << "Registration number: " << Reg[i] << endl;
cout << "Date: " << Date[i] << endl;
cout << "Month: " << Month[i] << endl;
cout << "Year: " << Year[i] << endl;
cout << "Crime: " << Crime[i] << endl;
cout << "Punishent: " << Penalty[i] << endl;
cout << "Change data of the criminal:" << endl;
cout << "Enter name: ";
cin.ignore(); // Clear the input buffer
getline(cin, Name[i]);
cout << "Enter age: ";
cin >> Age[i];
cout << "Enter registration number: ";
cin >> Reg[i];
cout << "Date (dd): ";
cin >> Date[i];
cout << "Month (mm): ";
cin >> Month[i];
cout << "Year (yyyy): ";
cin >> Year[i];
cout << "Crime: ";
cin.ignore(); // Clear the input buffer
getline(cin, Crime[i]);
cout << "Punishment: ";
cin.ignore();
getline(cin, Penalty[i]);
found = true;
break;
}
}
if (!found) {
cout << "Data not found." << endl;
}
}
void deleteRecords() {
int regnu;
cout << "Enter registration number of the criminal you want to delete: ";
cin >> regnu;
bool found = false;
for (int i = 0; i < Totalcriminal; i++) {
if (regnu == Reg[i]) {
found = true;
// Shift records to remove the deleted entry
for (int j = i; j < Totalcriminal-1; j++) { // Updated to 9 instead of 10 to avoid out-of-bounds
Name[j] = Name[j + 1];
Age[j] = Age[j + 1];
Reg[j] = Reg[j + 1];
Date[j] = Date[j + 1];
Month[j] = Month[j + 1];
Year[j] = Year[j + 1];
Crime[j] = Crime[j + 1];
Penalty[j] = Penalty[j + 1];
}
Totalcriminal--;
cout<<"Data has been deleted"<<endl;
break;
}
}
if (!found) {
cout << "Record not found." << endl;
}
}
};
// Base class with pure virtual function(abstract class)
class Criminal {
protected:
string name[100];
int age[100];
double reg[100];
int date[100];
int month[100];
int year[100];
string crime[100];
string penalty[100];
public:
int totalcriminal = 0;
virtual void displayDetails() = 0; // Pure virtual function
};
// Derived class for detailed operations(Inheritance)
class Detail : public Criminal {
public:
void input() {
int n;
cout << "Enter number of criminals: ";
cin >> n;
if (totalcriminal + n > 100) { // Check to avoid array overflow
cout << "Exceeds maximum number of criminals." << endl;
return;
}
for (int i = 0; i < totalcriminal + n; i++) {
cout << "Enter criminal details: " << i + 1 << endl;
cout << "Enter name: ";
cin.ignore(); // Clear the input buffer
getline(cin, name[i]);
cout << "Enter age: ";
cin >> age[i];
cout << "Enter registration number: ";
cin >> reg[i];
cout << "Date (dd): ";
cin >> date[i];
cout << "Month (mm): ";
cin >> month[i];
cout << "Year (yyyy): ";
cin >> year[i];
cout << "Crime: ";
cin.ignore(); // Clear the input buffer
getline(cin, crime[i]);
cout << "punishment : ";
getline(cin,penalty[i]);
}
totalcriminal += n;
}
void show() {
if (totalcriminal == 0) {
cout << "No data found." << endl;
} else {
for (int i = 0; i < totalcriminal; i++) {
cout << "Criminal details: " << i + 1 << endl;
cout << "Name: " << name[i] << endl;
cout << "Age: " << age[i] << endl;
cout << "Registration number: " << reg[i] << endl;
cout << "Date: " << date[i] << endl;
cout << "Month: " << month[i] << endl;
cout << "Year: " << year[i] << endl;
cout << "Crime: " << crime[i] << endl;
cout << "Punishment: " << penalty[i] << endl;
}
}
}
void search() {
cout << "Enter name of the criminal you want to search: ";
int j = 7;
char name[j];
for(int j = 0 ; j<7;j++){
cin>>name[j];
}
bool found = false;
for (int i = 0; i < totalcriminal; i++) {
if ( name[j]== name[i]) {
cout << "Criminal details are:" << endl;
cin.ignore();
cout << "Name: " << name[i] << endl;
cout << "Age: " << age[i] << endl;
cout << "Registration number: " << reg[i] << endl;
cout << "Date: " << date[i] << endl;
cout << "Month: " << month[i] << endl;
cout << "Year: " << year[i] << endl;
cin.ignore();
cout << "Crime: " << crime[i] << endl;
cout << "Punishment: " << penalty[i] << endl;
cin.ignore();
found = true;
break;
}
}
if (!found) {
cout << "No record found." << endl;
}
}
void change() {
double regno;
cout << "Enter registration number of criminal you want to change data of: ";
cin >> regno;
bool found = false;
for (int i = 0; i < totalcriminal; i++) {
if (regno == reg[i]) {
cout << "Previous data:" << endl;
cout << "Name: " << name[i] << endl;
cout << "Age: " << age[i] << endl;
cout << "Registration number: " << reg[i] << endl;
cout << "Date: " << date[i] << endl;
cout << "Month: " << month[i] << endl;
cout << "Year: " << year[i] << endl;
cout << "Crime: " << crime[i] << endl;
cout << "Punishment: " << penalty[i] << endl;
cout << "Change data of the criminal:" << endl;
cout << "Enter name: ";
cin.ignore(); // Clear the input buffer
getline(cin, name[i]);
cout << "Enter age: ";
cin >> age[i];
cout << "Enter registration number: ";
cin >> reg[i];
cout << "Date (dd): ";
cin >> date[i];
cout << "Month (mm): ";
cin >> month[i];
cout << "Year (yyyy): ";
cin >> year[i];
cout << "Crime: ";
cin.ignore(); // Clear the input buffer
getline(cin, crime[i]);
cout << "Punishment:";
cin.ignore();
getline(cin,penalty[i]);
found = true;
break;
}
}
if (!found) {
cout << "Data not found." << endl;
}
}
void deleteRecord() {
double regno;
cout << "Enter registration number of the criminal you want to delete: ";
cin >> regno;
bool found = false;
for (int i = 0; i < totalcriminal; i++) {
if (regno == reg[i]) {
found = true;
// Shift records to remove the deleted entry
for (int j = i; j < totalcriminal - 1; j++) {
name[j] = name[j + 1];
age[j] = age[j + 1];
reg[j] = reg[j + 1];
date[j] = date[j + 1];
month[j] = month[j + 1];
year[j] = year[j + 1];
crime[j] = crime[j + 1];
penalty[j] = penalty[j + 1];
}
totalcriminal--;
break;
}
}
if (!found) {
cout << "Record not found." << endl;
}
}
void displayDetails() override {
show(); // Use the existing show function (Polymorphism)
}
};
int main() {
cout << "\t\t\t\t\t\t*------------------------------*" << endl;
cout << "\t\t\t\t\t\t¦ Criminal RECORD SYSTEM ¦" << endl;
cout << "\t\t\t\t\t\t*------------------------------*" << endl;
Detail c;
functions d;
int press;
do {
cout << "MENU" << endl
<< "1. Show already registered criminals\n"
<< "2. Search registered criminal\n"
<< "3. Change data of registered criminal\n"
<< "4. Delete already existing data\n"
<< "5. Enter criminal's data.\n"
<< "6. Search criminal data.\n"
<< "7. Change data.\n"
<< "8. Show criminal data.\n"
<< "9. Delete criminal data.\n"
<< "10. EXIT" << endl;
cout << "Enter choice: ";
cin >> press;
switch (press) {
case 1:
d.show();
break;
case 2:
d.searched();
break;
case 3:
d.changes();
break;
case 4:
d.deleteRecords();
break;
case 5:
c.input();
break;
case 6:
c.search();
break;
case 7:
c.change();
break;
case 8:
c.displayDetails();
break;
case 9:
c.deleteRecord();
break;
case 10:
cout << "Exiting......" << endl;
break;
default:
cout << "Invalid choice. Please try again." << endl;
}
} while (press != 10);
cout << "\t\t\t-----------------END OF PROGRAM-----------------" << endl;
return 0;
}