forked from Rustam-Z/cpp-programming
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSource.cpp
More file actions
566 lines (526 loc) · 9.51 KB
/
Copy pathSource.cpp
File metadata and controls
566 lines (526 loc) · 9.51 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
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
#include <iostream>
#include <string>
#include <conio.h>
#include <time.h>
#include <Windows.h>
using namespace std;
// Functions declaration
void F_First_Program_Menu();
void F_Second_Program_Menu();
// Main BASE class for ALL classes
class Staff
{
protected:
string code;
string name;
public:
Staff()
{
code = "0000";
name = "Unknown";
}
/*void set_code(string code) {
this->code = code;
}
string get_code() {
return code;
}
void set_name(string name) {
this->name = name;
}
string get_name() {
return name;
}
*/
void getdata_name()
{
cout << " Enter employee name: ";
cin >> name;
}
void getdata_code()
{
cout << " Enter employee code: ";
cin >> code;
}
void showdata_name()
{
cout << " Name: " << name << endl;
}
void showdata_code()
{
cout << " Code: " << code << endl;
}
};
class Teacher : public Staff
{
protected:
string subject;
int publications;
public:
Teacher()
{
subject = "Unknown";
publications = 0;
}
void getdata()
{
Staff::getdata_code();
Staff::getdata_name();
cout << " Enter subject: ";
cin >> subject;
cout << " Enter number of publications: ";
cin >> publications;
}
void showdata()
{
Staff::showdata_code();
Staff::showdata_name();
cout << " Subject: " << subject << endl
<< " Publications: " << publications << endl;
}
};
class Officer : public Staff
{
protected:
float grade;
public:
Officer()
{
grade = 0.0;
}
void getdata()
{
Staff::getdata_code();
Staff::getdata_name();
cout << " Enter the grade: ";
cin >> grade;
}
void showdata()
{
Staff::showdata_code();
Staff::showdata_name();
cout << " Grade: " << grade << endl;
}
};
class Typist : public Staff
{
protected:
int speed;
public:
Typist()
{
speed = 0;
}
void getdata()
{
Staff::getdata_code();
Staff::getdata_name();
cout << " Enter the speed (wprds/min): ";
cin >> speed;
}
void showdata()
{
Staff::showdata_code();
Staff::showdata_name();
cout << " Speed (words/min): " << speed << endl;
}
};
class Regular_Typist : public Typist
{
protected:
float monthly_salary;
public:
Regular_Typist()
{
monthly_salary = 0.0;
}
void getdata()
{
Typist::getdata();
cout << " Enter the monthly salary: ";
cin >> monthly_salary;
}
void showdata()
{
Typist::showdata();
cout << " Monthly salary: " << monthly_salary << endl;
}
};
class Casual_Typist : public Typist
{
protected:
float daily_wage;
public:
Casual_Typist()
{
daily_wage = 0.0;
}
void getdata()
{
Typist::getdata();
cout << " Enter the daily wage: ";
cin >> daily_wage;
}
void showdata()
{
Typist::showdata();
cout << " Daily wage: " << daily_wage << endl;
}
};
// Second program classes
class Person
{
protected:
string name;
string code;
public:
Person()
{
name = "Unknown";
code = "Unknown";
}
void getdetails()
{
cout << " Enter name: ";
cin >> name;
cout << " Enter code: ";
cin >> code;
}
void showdetails()
{
cout << " NAME: " << name << endl;
cout << " CODE: " << code << endl;
}
};
class Account : virtual public Person
{
protected:
float pay;
public:
Account()
{
pay = 0.0;
}
void getpay()
{
cout << " Enter pay amount: ";
cin >> pay;
}
void showpay()
{
cout << " PAY: " << pay << endl;
}
};
class Admin : virtual public Person
{
protected:
int experience;
public:
Admin()
{
experience = 0;
}
void getexpr()
{
cout << " Enter experience in years: ";
cin >> experience;
}
void showexpr()
{
cout << " EXPERIENCE: " << experience << endl;
}
};
class Master : public Account, public Admin
{
public:
void create()
{
getdetails();
getpay();
getexpr();
}
void display()
{
showdetails();
showpay();
showexpr();
}
void update()
{
for (int i = 0; i < 1000; i++)
{
system("cls");
cout << "\t U P D A T E D E T A I L S\n";
cout << "=========================================\n";
cout << " Choose detail you want to update\n";
cout << " 1. NAME\n";
cout << " 2. CODE\n";
cout << " 3. EXPERIENCE\n";
cout << " 4. PAY\n";
cout << " 0. Back\n";
cout << " Your choice: ";
switch (_getch())
{
case 49:
cout << "\n\n Enter name: ";
cin >> name;
cout << " Successfully Updated!\n";
Sleep(0700);
Sleep(0700);
break;
case 50:
cout << "\n\n Enter code: ";
cin >> code;
cout << " Successfully Updated!\n";
Sleep(0700);
Sleep(0700);
break;
case 51:
cout << "\n\n Enter Expereince: ";
cin >> experience;
cout << " Successfully Updated!\n";
Sleep(0700);
Sleep(0700);
break;
case 52:
cout << "\n\n Enter pay: ";
cin >> pay;
cout << " Successfully Updated!\n";
Sleep(0700);
Sleep(0700);
break;
case 48:
i = 1000;
break;
default:
cout << endl
<< endl;
cout << "\t\t Your choice is not abailable in Menu. \n\t\t Please try one more time.\n";
Sleep(0700);
Sleep(0700);
} // switch
}
} // for loop
};
int main()
{
for (int k = 0; k < 1000; k++)
{
system("cls");
cout << "\tM A I N M E N U\n";
cout << " =====================\n";
cout << " 1. First program\n";
cout << " 2. Second program\n";
cout << " 0. Exit\n";
cout << " Your choice: \n";
switch (_getch())
{
case '1':
{
cout << "\t Educational institution database\n";
// calling the menu of first program
F_First_Program_Menu();
}
break;
case '2':
{
cout << "\t Second program\n";
// calling the menu of second program
F_Second_Program_Menu();
}
break;
case '0':
{
return 0;
break;
}
default:
{
cout << endl
<< endl;
cout << "\t\t Your choice is not abailable in Menu. \n\t\t Please try one more time.\n";
Sleep(0700);
Sleep(0700);
}
break;
} // switch
} // for loop
system("pause");
return 0;
}
void F_First_Program_Menu()
{
// objects
Teacher teacher;
Officer officer;
Regular_Typist regular;
Casual_Typist casual;
for (int k = 0; k < 1000; k++)
{
system("cls");
cout << "\tM A I N M E N U\n";
cout << " =====================\n";
cout << " 1. TEACHER\n";
cout << " 2. OFFICER\n";
cout << " 3. TYPIST\n";
cout << " 0. Back\n";
cout << " Your choice: \n";
switch (_getch())
{
case '1':
{
system("cls");
cout << "\t T E A C H E R\n";
cout << "===================================\n";
teacher.getdata();
cout << "\n\n\tThe given information:\n";
cout << "===================================\n";
teacher.showdata();
cout << endl
<< endl;
system("pause");
}
break;
case '2':
{
system("cls");
cout << "\t O F F I C E R\n";
cout << "===================================\n";
officer.getdata();
cout << "\n\n\tThe given information:\n";
cout << "===================================\n";
officer.showdata();
cout << endl
<< endl;
system("pause");
}
break;
case '3':
{
for (int l = 0; l < 1000; l++)
{
system("cls");
cout << "\t T Y P I S T\n";
cout << "===================================\n";
cout << " 1. Regular typist\n";
cout << " 2. Casual typist\n";
cout << " 0. Back\n";
cout << " Your choice: \n";
switch (_getch())
{
case '1':
{
system("cls");
cout << "\t R E G U L A R T Y P I S T\n";
cout << "===================================\n";
regular.getdata();
cout << "\n\n\tThe given information:\n";
cout << "===================================\n";
regular.showdata();
cout << endl
<< endl;
system("pause");
}
break;
case '2':
{
system("cls");
cout << "\t C A S U A L T Y P I S T\n";
cout << "===================================\n";
casual.getdata();
cout << "\n\n\tThe given information:\n";
cout << "===================================\n";
casual.showdata();
cout << endl
<< endl;
system("pause");
}
break;
case '0':
{
system("cls");
l = 1000;
}
break;
default:
{
cout << endl
<< endl;
cout << "\t\t Your choice is not abailable in Menu. \n\t\t Please try one more time.\n";
Sleep(0700);
Sleep(0700);
}
break;
} // switch
} // for
}
break;
case '0':
{
system("cls");
k = 1000;
}
break;
default:
{
cout << endl
<< endl;
cout << "\t\t Your choice is not abailable in Menu. \n\t\t Please try one more time.\n";
Sleep(0700);
Sleep(0700);
}
break;
} // switch
} // for loop
}
void F_Second_Program_Menu()
{
Master master1; // object
for (int k = 0; k < 1000; k++)
{
system("cls");
cout << "\t M A S T E R'S D A T A B A S E\n";
cout << " ====================================\n";
cout << " 1. Create Record\n";
cout << " 2. Display Record\n";
cout << " 3. Update Record\n";
cout << " 0. Back\n";
cout << " Your choice: \n";
switch (_getch())
{
case '1':
system("cls");
cout << "\t C R E A T E A R E C O R D\n";
cout << "===========================================\n";
master1.create();
cout << endl
<< endl;
system("pause");
break;
case '2':
system("cls");
cout << "\t D I S P L A Y D E T A I L S\n";
cout << "==========================================\n";
master1.display();
cout << endl
<< endl;
system("pause");
break;
case '3':
system("cls");
master1.update();
cout << endl
<< endl;
// system("pause");
break;
case '0':
k = 1000;
break;
default:
cout << "\t\t Your choice is not abailable in Menu. \n\t\t Please try one more time.\n";
Sleep(0700);
Sleep(0700);
break;
} // switch
} // for loop
}