-
Notifications
You must be signed in to change notification settings - Fork 1
/
Source.cpp
620 lines (560 loc) · 15.2 KB
/
Source.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
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
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
#include <iostream>
#include <string>
#include <iomanip>
#include <conio.h>
#include <windows.h>
#include <stdlib.h>
#define DANESHJUHA 1000
#define MaX 50
using namespace std;
//*********** LESSON CLASS ***************
class dars
{
protected:
float gheymat;
string esm;
string code;
int vahed;
public:
dars();
dars(string , string ,int , float );
string tostring();
virtual string noe()
{
return "all";
}
virtual void print()
{
cout << left << setw(15) << code << setw(20) << esm <<setw(10) << "" << setw(8) << vahed << fixed << fixed << setprecision(2) << setw(10) << gheymat << endl;
}
int getVahed();
float getGheymat();
string getCode();
};
//******** LESSON CLASS FUNCTIONS *********
dars::dars(){}
dars::dars(string esmeDars, string codeDars,int tedadVahed, float gheymateDars)
{
esm = esmeDars;
code = codeDars;
gheymat = gheymateDars;
vahed = tedadVahed;
}
string dars::tostring()
{
return esm;
}
int dars::getVahed()
{
return vahed;
}
float dars::getGheymat()
{
return gheymat;
}
string dars::getCode()
{
return code;
}
//******** NAZARI CLASS (derived of lesson class) *********
class nazari:public dars
{
public:
nazari(string , string , float ,int );
virtual string noe()
{
return "nazari";
}
void print();
};
//******** NAZARI CLASS FUNCTIONS *********
nazari::nazari(string esmeDars, string codeDars, float gheymateDars ,int tedadVahed)
{
esm = esmeDars;
code = codeDars;
gheymat = gheymateDars;
vahed = tedadVahed;
}
void nazari::print()
{
cout << left << setw(15) << code << setw(20) << esm <<setw(10) << "nazari" << setw(8) << vahed << fixed << setprecision(2) << setw(10) << gheymat << endl;
}
//******** AMALI CLASS (derived of lesson class) *********
class amali:public dars
{
public:
amali(string , string , float ,int );
virtual string noe();
virtual void print();
};
//******** AMALI CLASS FUNCTIONS *********
amali::amali(string esmeDars, string codeDars, float gheymateDars ,int tedadVahed)
{
esm = esmeDars;
code = codeDars;
gheymat = gheymateDars;
vahed = tedadVahed;
}
string amali::noe()
{
return "amali";
}
void amali::print()
{
cout << left << setw(15) << code << setw(20) << esm <<setw(10) << "amali" << setw(8) << vahed << fixed << setprecision(2) << setw(10) << gheymat << endl;
}
//******** BARNAME CLASS *********
class barname
{
private:
string darsha[25];//code dars zakhire mishavad
int top;
float nomreha[25];
int findDars(string code)
{
for(int i = 0 ; i < top ; i++)
if(darsha[i] == code)
return i;
return -1;
}
int findDars(dars *list[], int size, string code)
{
for(int i = 0 ; i < size; i++)
if(list[i]->getCode() == code)
return i;
return -1;
}
public:
barname()
{
top = 0;
for(int i = 0 ; i < 25 ;nomreha[i++] = -1);
}
bool ezafeDars(string codeDars)
{
if(top == 25)
return false;
if(findDars(codeDars) == -1)
darsha[top++] = codeDars;
return true;
}
bool ezafeNomreh(string code, float nomreh)
{
int andis = findDars(code);
if(andis == -1)
return false;
if(nomreh < 0) nomreh = 0;
if(nomreh > 20) nomreh = 20;
nomreha[andis] = nomreh;
return true;
}
float moaddel(dars *listDarsha[], int size)
{
float majmueNomreh = 0;
int majmueVahed = 0;
for(int i = 0 ; i < top ; i++)
{
int andis = findDars(listDarsha, size, darsha[i]);
majmueNomreh += nomreha[i]*listDarsha[andis]->getVahed();
majmueVahed += listDarsha[andis]->getVahed();
}
return majmueNomreh/majmueVahed;
}
float shahriye(dars *listDarsha[], int size)
{
float majmueShahriye = 0;
for(int i = 0 ; i < top ; i++)
{
int andis = findDars(listDarsha, size, darsha[i]);
majmueShahriye += listDarsha[andis]->getGheymat();
}
return majmueShahriye;
}
void chaap(dars *listDarsha[], int size)
{
cout << left << setw(10) << "code"
<< setw(15) << "esme dars"
<< setw(10) << "noe"
<< setw(9) << "vahed"
<< setw(7) << "nomreh" << endl << endl;
for(int i = 0 ; i < top ; i++)
{
int andis = findDars(listDarsha, size, darsha[i]);
cout << left << setw(10) << listDarsha[andis]->getCode()
<< setw(15) << listDarsha[andis]->tostring()
<< setw(10) << listDarsha[andis]->noe()
<< setw(9) << listDarsha[andis]->getVahed()
<< fixed << setprecision(2) << setw(7) << nomreha[i] << endl;
}
float Moadel = moaddel(listDarsha, size);
cout << "\n\n\t\tMoaddel : " << fixed << setprecision(2) << Moadel;
cout << "\t\tShahriye : " << fixed << setprecision(2) << shahriye(listDarsha, size) ;
if(Moadel < 12)
{
cout << "\n\t\t\tMASHRUT";
}
else if(Moadel < 17)
{
cout << "\n\t\t\tGHEYREE MASHRUT";
}
else
cout << "\n\t\t\tMOMTAZ";
}//end chaap
};
//******** DANESHJU CLASS *********
class daneshju
{
private:
barname term;
string esm;
string family;
string pedar;
string shomare;
string codeMelli;
public:
daneshju(string Esm, string Family, string Pedar, string shomareDaneshjui, string CodeMelli)
{
esm=Esm; family=Family; pedar=Pedar; shomare=shomareDaneshjui; codeMelli=CodeMelli;
}
string getshomare()
{
return shomare;
}
string getesm()
{
return esm;
}
string getfamily()
{
return family;
}
void ezafeDars(string code)
{
if(!term.ezafeDars(code))
cout << "\nlist por ast.";
}
void ezafeNomreh(string codeDars, float nomreh)
{
if(!term.ezafeNomreh(codeDars, nomreh))
cout << "\nDars ba code " << codeDars << " vojud nadarad.";
}
float moaddel(dars *listDarsha[], int size)
{
return term.moaddel(listDarsha, size);
}
float shahriye(dars *listDarsha[], int size)
{
return term.shahriye(listDarsha, size);
}
void chaapeBarname(dars *listDarsha[], int size)
{
term.chaap(listDarsha, size);
}
void chaap()
{
cout << left << "esm : " << setw(20) << esm << " family : " << setw(20) << family << " Pedar : " << setw(20) << pedar << endl;
cout << left << "shomare daneshjui : " << setw(10) << shomare << " shomare melli : " << codeMelli << endl << endl;
}
};
//******** Global FUNCTIONS *********
int findDaneshju(daneshju *daneshjuha[], int size, string shomareDaneshjui)
{
for(int i = 0 ; i < size ; i++)
if(daneshjuha[i]->getshomare() == shomareDaneshjui)
return i;
return -1;
}
int findDars(dars *list[], int size, string code)
{
for(int i = 0 ; i < size; i++)
if(list[i]->getCode() == code)
return i;
return -1;
}
void header()
{
//__First Line_________________________________________
cout<<char(201)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(187);
//__Second Line_________________________________________
cout<<endl<<char(186)<<" IAUCTB University System App "<<char(186)<<endl;
//__third Line_________________________________________
cout<<char(200)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(188)<<endl;
}
void clrscr()
{
system("cls");
header();
}
char menu();
void headerDars()
{
cout << left << setw(15) << "code" << setw(20) << "esm" <<setw(10) << "noe" << setw(8) << "vahed" << setw(10) << "gheymat" << endl;
}
void headerDaneshju()
{
cout << left << setw(20) << "Shomare daneshjui" << setw(20) << "esm" <<setw(20) << "family" << endl;
}
//_________________________________________________
/////////////////Main Function\\\\\\\\\\\\\\\\\\\\\\
int main()
{
//System commands :
system("color 81");
system("mode 100,40");
void logo();
logo();
dars *list[MaX];
int top = 0;
daneshju *daneshjuha[DANESHJUHA];
int topSt = 0;
bool end = false;
while(!end)
{
clrscr();
char choice = menu();
switch(choice)
{
case 'a'://ezafe dars
{
clrscr();
string code;
cout << "Lotfan code dars ra vared konid : ";
cin >> code;
cin.get();
if(findDars(list, top, code) != -1)
{
cout << "\nin dars mojud ast.";
break;
}
else
{
string esm;
float gheymat;
int vahed;
char noe='0';
cout << "\nEsme dars : " ;
getline(cin, esm);
cout << "tedad vahed (use numbers) : ";
cin >> vahed;
cout << "gheymat (use numbers) : ";
cin >> gheymat;
cout << "noe (1. nazari, 2. amali) [1-2] : ";
for(noe;noe!=1||noe!=2;)
{
cin >> noe;
if(noe == '1')
{
list[top++] = new nazari(esm, code, gheymat, vahed);
break;
}
else if(noe == '2')
{
list[top++] = new amali(esm, code, gheymat, vahed);
break;
}
else
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED);
cout << "Adade vared shode na dorost ast.";
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_BLUE|BACKGROUND_GREEN);
cout << "\nnoe (1. nazari, 2. amali) [1-2] : ";
}
}
}
break;
}//end case a
case 'b'://ezafe daneshju
{
clrscr();
string shomare;
cout << "Shomare daneshjuyi ra vared konid : ";
cin >> shomare;
if(findDaneshju(daneshjuha, topSt, shomare) != -1)
{
cout << "\ndaneshju ba in shomare mojud ast\n\n";
daneshjuha[findDaneshju(daneshjuha, topSt, shomare)]->chaap();
break;
}
else
{
string esm, family, meli, pedar;
cout << "\nEsm : ";
cin.get();
getline(cin, esm);
cout << "Family : ";
getline(cin, family);
cout << "Name pedar : ";
getline(cin, pedar);
cout << "Code melli : ";
cin >> meli;
daneshjuha[topSt++] = new daneshju(esm, family, pedar, shomare, meli);
}
break;
}//end case b
case 'c'://entekhab vahed
{
clrscr();
string shomare;
cout << "Shomare daneshjui ra vared konid : ";
cin >> shomare;
int andis = findDaneshju(daneshjuha, topSt, shomare);
if(andis == -1)
{
cout << "Daneshju ba in shomare sabt nashode.";
break;
}
else
{
clrscr();
string sd;
daneshjuha[andis]->chaap();
cout << endl << endl;;
cout << "Shomare dars baraye etmam 0 ra vared konid : ";
cin >> sd;
while(sd != "0")
{
clrscr();
int dd = findDars(list, top, sd);
if(dd == -1)
cout << "\nDars ba in shomare mojud nist. \n";
else
{
daneshjuha[andis]->ezafeDars(sd);
}
daneshjuha[andis]->chaapeBarname(list, top);
cout << endl << endl;
cout << "Shomare dars baraye etmam 0 ra vared konid : ";
cin >> sd;
}//end while
break;
}
}//end case c
case 'd'://liste darsha
{
clrscr();
headerDars();
cout << endl;
for(int i = 0 ; i < top ; i++)
list[i]->print();
break;
}//end case d
case 'e':
{
clrscr();
headerDaneshju();
for(int i = 0 ; i < topSt; i++)
cout << left << setw(20) << daneshjuha[i]->getshomare() << setw(20) << daneshjuha[i]->getesm() <<setw(20) << daneshjuha[i]->getfamily() << endl;
break;
}//end case e
case 'f'://sabte nomreha
{
clrscr();
string shomare, code;
float nomreh;
cout << "Shomare daneshjui ra vared konid : ";
cin >> shomare;
int andis = findDaneshju(daneshjuha, topSt, shomare);
if(andis == -1)
{
cout << "Daneshju ba in shomare sabt nashode.";
break;
}
else
{
clrscr();
daneshjuha[andis]->chaapeBarname(list, top);
cout << endl << endl;;
cout << "Shomare dars baraye etmam 0 ra vared konid : ";
cin >> code;
while(code != "0")
{
int dd = findDars(list, top, code);
if(dd == -1)
{
cout << "\nDars ba in shomare mojud nist. \n";
_getch();//getch(); MSDN warning
}
else
{
cout << "\nNomreh ra vared konid : ";
cin >> nomreh;
daneshjuha[andis]->ezafeNomreh(code, nomreh);
}
clrscr();
daneshjuha[andis]->chaapeBarname(list, top);
cout << endl << endl;
cout << "Shomare dars baraye etmam 0 ra vared konid : ";
cin >> code;
}//end while
break;
}
}//end case f
case 'g'://karnaameh
{
clrscr();
string shomare;
cout << "Shomare daneshjuyi ra vared konid : ";
cin >> shomare;
int andis = findDaneshju(daneshjuha, topSt, shomare);
if(andis == -1)
{
cout << "Daneshju ba in shomare sabt nashode. ";
break;
}
else
{
clrscr();
daneshjuha[andis]->chaapeBarname(list, top);
}
break;
}//end case g
case 'h' :
{
end = true;
break;
}
}//end switch
cout << "\n\n\t\t\t";
system("pause");
}//end while
return 0;
}
//_________________________________________________
/////////////////Local Functions\\\\\\\\\\\\\\\\\\\
void logo()
{
cout<<"\n\n\n\n";
cout<<"\t\t\t @@@@ @@@ @@ @@ @@@@@@ @@@@@@@@ @@@@@@@@"<<endl;Sleep(500);system("color 2B");
cout<<"\t\t\t @@ @@ @@ @@ @@ @@ @@ @@ @@ @@"<<endl ;Sleep(500);system("color 3C");
cout<<"\t\t\t @@ @@ @@ @@ @@ @@ @@ @@ @@"<<endl ;Sleep(500);system("color 4D");
cout<<"\t\t\t @@ @@ @@ @@ @@ @@ @@ @@@@@@@@"<<endl ;Sleep(500);system("color 5E");
cout<<"\t\t\t @@ @@@@@@@@@ @@ @@ @@ @@ @@ @@"<<endl ;Sleep(500);system("color 6F");
cout<<"\t\t\t @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ "<<endl ;Sleep(500);system("color B2");
cout<<"\t\t\t @@@@ @@ @@ @@@@@@@ @@@@@@ @@ @@@@@@@@ "<<endl<<endl ;Sleep(500);system("color 3C");
cout<<"\t\t\t All rights reserved for Creator (C) May 2012"<<endl<<endl;Sleep(500);system("color 2F");
cout<<"\t\t\t \t ";
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_BLUE|BACKGROUND_RED|BACKGROUND_GREEN|BACKGROUND_INTENSITY);
cout<<" Moein Iranshahi "<<endl;
Sleep(4000);
}
//----------------------------------------------------------------------------------
char menu()
{
system("color 81");
char choice = '0';
do
{
clrscr();
cout << "A. Ezafe kardane dars\n"
<< "B. Ezafe kardane daneshju\n"
<< "C. Entekhab vahed\n"
<< "D. Namayesh Doroos\n"
<< "E. Namayeshe Daneshjuyan\n"
<< "F. Sabte nomaraat\n"
<< "G. karname\n"
<< "H. Khorooj\n\n"
<< "Yeki az gozine haye bala ra Entekhab konid (A-H) : ";
choice=_getch();
}while(choice < 'a' || choice > 'h');
return choice;
}