-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSource.cpp
More file actions
979 lines (868 loc) · 23.2 KB
/
Source.cpp
File metadata and controls
979 lines (868 loc) · 23.2 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
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
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <memory>
using namespace std;
class exceptie_nota :std::exception {
public:
const char* what() {
return "Nota poate fi maxim 10\n";
}
};
class proiect {
private:
char* nume_proiect;
double nota_proiect;
static proiect* instancePtr;
public:
proiect() {
nume_proiect = nullptr;
nota_proiect = 0;
}
~proiect() {
delete[]nume_proiect;
}
proiect(char f[], double x) {
nume_proiect = new char[strlen(f) + 1];
strcpy(nume_proiect, f);
nota_proiect = x;
try {
if (nota_proiect > 10)
{
throw exceptie_nota();
}
}
catch (exceptie_nota ex) {
cout << ex.what();
nota_proiect = 10;
}
}
void setproiect(char f[], double x) {
if (nume_proiect != nullptr)
delete[]nume_proiect;
nume_proiect = new char[strlen(f) + 1];
strcpy(nume_proiect, f);
nota_proiect = x;
try {
if (nota_proiect > 10)
{
throw exceptie_nota();
}
}
catch (exceptie_nota ex) {
cout << ex.what();
nota_proiect = 10;
}
}
char* getnumeproiect() {
return nume_proiect;
}
double getnotaproiect() {
return nota_proiect;
}
};
class activitate {
private:
shared_ptr<double[]> nota_activitate = shared_ptr<double[]>(new double[25]);
int numar_note;
public:
activitate() {
for (int i = 0; i < 25; i++)
nota_activitate[i] = 0;
numar_note = 0;
}
~activitate() {
}
activitate(double v[], int n) {
numar_note = n;
int num = 0;
for (int i = 0; i < numar_note; i++)
{
nota_activitate[i] = v[i];
try {
if (nota_activitate[i] > 10 && num != 1)
{
num = 1;
throw exceptie_nota();
}
}
catch (exceptie_nota ex) {
cout << ex.what();
nota_activitate[i] = 10;
}
}
}
void setactivitate(shared_ptr<double[]> v, int n) {
numar_note = n;
int num = 0;
for (int i = 0; i < numar_note; i++)
{
nota_activitate[i] = v[i];
try {
if (nota_activitate[i] > 10 && num != 1)
{
num = 1;
throw exceptie_nota();
}
}
catch (exceptie_nota ex) {
cout << ex.what();
nota_activitate[i] = 10;
}
}
}
double medie_activitate() {
double suma = 0;
for (int i = 0; i < numar_note; i++) {
suma += nota_activitate[i];
}
if (numar_note != 0)
return suma / numar_note;
else
return 0;
}
int getnumarnote() {
return numar_note;
}
shared_ptr<double[]> getnote() {
return nota_activitate;
}
};
class student {
private:
proiect ob_proiect;
activitate ob_activitate;
char* nume;
public:
student() {
nume = nullptr;
}
~student() {
delete[]nume;
}
student(char s[], double v[], int n, char f[], double x) :ob_activitate(v, n), ob_proiect(f, x)
{
nume = new char[strlen(s) + 1];
strcpy(nume, s);
}
student(student& x) {
nume = new char[strlen(x.nume) + 1];
strcpy(nume, x.nume);
ob_activitate.setactivitate(x.ob_activitate.getnote(), x.ob_activitate.getnumarnote());
ob_proiect.setproiect(x.ob_proiect.getnumeproiect(), x.ob_proiect.getnotaproiect());
}
void setstudent(char s[]) {
if (nume != nullptr)
delete[]nume;
nume = new char[strlen(s) + 1];
strcpy(nume, s);
}
void setactivitatestudent(shared_ptr <double[]> v, int n) {
ob_activitate.setactivitate(v, n);
}
void setproiectstudent(char f[], double z) {
ob_proiect.setproiect(f, z);
}
char* getstudent() {
return nume;
}
char* getproiectstudent() {
return ob_proiect.getnumeproiect();
}
double getmediestudent() {
return ob_activitate.medie_activitate();
}
double getnotaproiectstudent() {
return ob_proiect.getnotaproiect();
}
void operator=(student& x) {
if (nume != nullptr)
delete[]nume;
nume = new char[strlen(x.nume) + 1];
strcpy(nume, x.nume);
ob_activitate.setactivitate(x.ob_activitate.getnote(), x.ob_activitate.getnumarnote());
ob_proiect.setproiect(x.ob_proiect.getnumeproiect(), x.ob_proiect.getnotaproiect());
}
friend ostream& operator<<(ostream& out, student& s);
friend istream& operator>>(istream& in, student& s);
};
ostream& operator<<(ostream& out, student& s) {
if (s.getstudent() != nullptr) {
out << "Studentul " << s.getstudent() << " are urmatoarele note: ";
shared_ptr<double[]> v;
v = s.ob_activitate.getnote();
for (int i = 0; i < s.ob_activitate.getnumarnote() - 1; i++) {
out << v[i] << ", ";
}
out << v[s.ob_activitate.getnumarnote() - 1] << " si a realizat proiectul " << s.ob_proiect.getnumeproiect() << ". Nota proiect: " << s.ob_proiect.getnotaproiect();
out << "\n";
}
else
out << "Nu exista studentul\n";
return out;
}
istream& operator>>(istream& in, student& s) {
cout << "Numele studentului: ";
char nume[25], numeproiect[25];
int n;
double z;
shared_ptr<double[]>v(new double[25]);
in.ignore();
in.getline(nume, 25);
s.setstudent(nume);
cout << "Numarul de note pentru activitate: ";
in >> n;
cout << "Notele: ";
for (int i = 0; i < n; i++) {
in >> v[i];
}
s.ob_activitate.setactivitate(v, n);
cout << "Numele proiectului: ";
in.ignore();
in.getline(numeproiect, 25);
cout << "Nota proiect: ";
in >> z;
s.ob_proiect.setproiect(numeproiect, z);
in.ignore();
return in;
}
class pondere {
private:
double pr;
double ac;
public:
pondere() {
ac = 0.5;
pr = 0.5;
}
void setpondere(int a, int b) {
ac = double(a) / 100;
pr = double(b) / 100;
}
void setpondere(double a, double b)
{
ac = a;
pr = b;
}
double getpondereac() {
return ac;
}
double getponderepr() {
return pr;
}
};
class exceptie_ponderi : public std::exception {
public:
string mesaj() {
return "!Eroare: ponderi invalide!\n";
}
string corectare() {
return "!Eroarea a fost corectata!\nPonderi noi: ";
}
};
class medie_finala {
private:
double nota_pr;
double nota_ac;
pondere p;
public:
medie_finala() {
nota_ac = 0;
nota_pr = 0;
}
medie_finala(double a, double b) :nota_ac(a), nota_pr(b) {}
void mediecupondere(int pondereac, int ponderepr) {
try {
if (pondereac + ponderepr > 100) {
throw exceptie_ponderi();
}
}
catch (exceptie_ponderi ex) {
cout << ex.mesaj();
int z = pondereac + ponderepr;
pondereac = (pondereac * 100) / z;
ponderepr = (ponderepr * 100) / z;
if (pondereac + ponderepr != 100) {
if (pondereac > ponderepr)
pondereac += 100 - pondereac - ponderepr;
else
ponderepr += 100 - pondereac - ponderepr;
}
cout << ex.corectare() << pondereac << " " << ponderepr << "\n";
}
p.setpondere(pondereac, ponderepr);
}
void mediecupondere(double pondereac, double ponderepr) {
try {
if (pondereac + ponderepr > 1) {
throw exceptie_ponderi();
}
}
catch (exceptie_ponderi ex) {
cout << ex.mesaj();
double z = ceil((pondereac + ponderepr) * 100);
pondereac = ceil(pondereac * 100);
ponderepr = ceil(ponderepr * 100);
ponderepr = floor((ponderepr * 100) / z);
pondereac = floor((pondereac * 100) / z);
if (pondereac + ponderepr < 100)
{
if (pondereac > ponderepr) {
pondereac += 100 - pondereac - ponderepr;
}
else
ponderepr += 100 - pondereac - ponderepr;
}
pondereac = (double)pondereac / 100;
ponderepr = (double)ponderepr / 100;
cout << ex.corectare() << pondereac << " " << ponderepr << "\n";
}
p.setpondere(pondereac, ponderepr);
}
double calcul() {
return nota_pr * p.getponderepr() + nota_ac * p.getpondereac();
}
};
class profesor_baza {
public:
virtual ~profesor_baza() { }
virtual void seteaza_nume(char nume[]) = 0;
virtual void seteaza_materie(char materie[]) = 0;
virtual void seteaza_numar_ore(int x) = 0;
};
class profesor :public profesor_baza {
private:
static int numar_profesori;
char* numep;
char* materiep;
int numar_ore;
public:
profesor() {
numep = nullptr;
materiep = nullptr;
numar_ore = 0;
}
static void incrementare_prof() {
numar_profesori++;
}
static int numar_prof() {
return numar_profesori;
}
void seteaza_nume(char nume[]) {
if (numep != nullptr)
delete[]numep;
numep = new char[strlen(nume) + 1];
strcpy(numep, nume);
}
void seteaza_numar_ore(int x) {
numar_ore = x;
}
void seteaza_materie(char materie[]) {
if (materiep != nullptr)
delete[]materiep;
materiep = new char[strlen(materie) + 1];
strcpy(materiep, materie);
}
friend istream& operator>>(istream& in, profesor& p);
~profesor() {
delete[]numep;
delete[]materiep;
}
void afisare_prof() {
cout << "Profesorul " << numep << " preda materia " << materiep << " si are " << numar_ore << " ore pe saptmana.\n";
}
};
istream& operator>>(istream& in, profesor& p) {
cout << "Numele profesorului: ";
char nume[50], materie[50];
int numar_ore;
in.ignore();
in.getline(nume, 50);
p.seteaza_nume(nume);
cout << "Numele materiei predate: ";
in.ignore();
in.getline(materie, 50);
p.seteaza_materie(materie);
cout << "Numarul de ore pe saptamana: ";
in >> numar_ore;
in.ignore();
p.seteaza_numar_ore(numar_ore);
return in;
}
class amfiteatru {
protected:
~amfiteatru() {}
string nume_amf;
amfiteatru() { }
amfiteatru(string nume) {
nume_amf = nume;
}
};
class data_conf {
protected:
int zi, luna;
~data_conf() {}
data_conf() { zi = 0; luna = 0; }
data_conf(int a, int b) {
zi = a;
luna = b;
}
virtual string tip_data(int zi1, int luna1) {
string zi_final, luna_final;
if (zi < 10 && luna < 10)
{
zi_final = "0" + to_string(zi1);
luna_final = "0" + to_string(luna1);
}
else
if (zi >= 10 && luna >= 10)
{
zi_final = to_string(zi1);
luna_final = to_string(luna1);
}
else
if (zi >= 10 && luna < 10)
{
zi_final = to_string(zi1);
luna_final = "0" + to_string(luna1);
}
else
if (zi < 10 && luna >= 10)
{
zi_final = "0" + to_string(zi1);
luna_final = to_string(luna1);
}
return zi_final + "." + luna_final;
}
};
class conferinta :public amfiteatru, public data_conf {
private:
string nume_conf;
public:
~conferinta() {}
conferinta() :amfiteatru(), data_conf() {}
conferinta(string x, string y, int b, int c) :amfiteatru(y), data_conf(b, c) {
nume_conf = x;
}
void setconferinta(string x, string y, int b, int c) {
nume_amf = y;
zi = b;
luna = c;
nume_conf = x;
}
void afisareconferinta() {
cout << "In data de " << tip_data(zi, luna) << ", in amfiteatrul " << nume_amf << ", va avea loc conferinta \"" << nume_conf << "\"\n\n";
}
string afisare_data_conf() {
return "Conferinta " + nume_conf + " are loc pe data de " + tip_data(zi, luna);
}
friend istream& operator>>(istream& in, conferinta& s);
};
class exceptie_zi :public std::exception {
public:
string eroare_zi() {
return "O zi poate fi numerotata de la 1-31\nIntrodu ziua din nou: ";
}
};
class exceptie_luna :public std::exception {
public:
string eroare_luna() {
return "O luna poate fi numerotata de la 1-12\nIntrodu luna din nou: ";
}
};
istream& operator>>(istream& in, conferinta& c) {
string nume_conf, nume_amf;
int luna, zi;
cout << "Numele conferintei: ";
in.ignore();
getline(in, nume_conf);
cout << "Numele amfiteatrului: ";
getline(in, nume_amf);
cout << "Ziua si luna: ";
in >> zi >> luna;
int ok1 = 0;
while (ok1 == 0) {
try {
if (zi < 1 || zi>31)
throw exceptie_zi();
else
ok1 = 1;
}
catch (exceptie_zi ex) {
cout << ex.eroare_zi();
cin >> zi;
try {
if (luna < 1 || luna>12)
throw exceptie_luna();
else
ok1 = 1;
}
catch (exceptie_luna ex1) {
cout << ex1.eroare_luna();
cin >> luna;
}
}
}
in.ignore();
c.setconferinta(nume_conf, nume_amf, zi, luna);
return in;
}
class anunt {
protected:
string text_anunt;
public:
virtual void afisare_anunt() = 0;
void set_text(string x) { text_anunt = x; }
virtual ~anunt() { }
};
class important :public anunt {
public:
void afisare_anunt() {
string stele(text_anunt.length() + 2, ' ');
cout << "\n";
fill(stele.begin(), stele.begin() + text_anunt.length() + 2, '*');
cout << "\n";
cout << stele << "\n*" << text_anunt << "*\n" << stele << "\n";
}
};
class uzual :public anunt {
public:
~uzual() {}
void afisare_anunt() {
string stele(text_anunt.length() + 2, ' ');
cout << "\n";
fill(stele.begin(), stele.begin() + text_anunt.length() + 2, '-');
cout << "\n";
cout << stele << "\n|" << text_anunt << "|\n" << stele << "\n";
}
};
class reclama :public anunt {
public:
~reclama() {}
void afisare_anunt() {
string stele(text_anunt.length() + 2, ' ');
cout << "\n";
fill(stele.begin(), stele.begin() + text_anunt.length() + 2, '.');
cout << "\n";
cout << stele << "\n(" << text_anunt << ") - Poti ignora!\n" << stele << "\n";
}
};
class extrem :public anunt {
public:
~extrem() {}
void afisare_anunt() {
string stele(text_anunt.length() + 2, ' ');
cout << "\n";
fill(stele.begin(), stele.begin() + text_anunt.length() + 2, '!');
cout << "\n";
cout << stele << "\n!" << text_anunt << "!\n" << stele << "\n";
}
};
class decidere_tip {
private:
anunt* p_anunt;
public:
decidere_tip(int tip)
{
if (tip == 0)
p_anunt = new uzual();
else if (tip == 1)
p_anunt = new important();
else if (tip == 2)
p_anunt = new extrem();
else if (tip == 3)
p_anunt = new reclama();
else
p_anunt = NULL;
}
~decidere_tip() {
if (p_anunt) {
delete p_anunt;
p_anunt = NULL;
}
}
anunt* getanunt() { return p_anunt; }
};
double medii[25], medii_copie[25];
int contor = 0, contor_conf = 0;
int profesor::numar_profesori = 0;
int main() {
int a, ok = 1;
int tipcopie = -1, ac = 0, pr = 0;
double ac1, pr1;
student studentul[25];
conferinta conf[25];
profesor profesorul[25];
vector <anunt*>anuntul;
char numele0[25] = "Popescu Ion", numeleproiect0[25] = "Referat Istorie";
int numaruldenote0 = 3;
shared_ptr<double[]> notele0(new double[25]);
notele0[0] = 4.5;
notele0[1] = 10;
notele0[2] = 6;
double notaproiectului0 = 7.6;
studentul[0].setstudent(numele0);
studentul[0].setactivitatestudent(notele0, numaruldenote0);
studentul[0].setproiectstudent(numeleproiect0, notaproiectului0);
contor++;
char numele1[25] = "Vasilescu Vasile", numeleproiect1[25] = "Referat Chimie";
int numaruldenote1 = 5;
shared_ptr<double[]> notele1(new double[25]);
notele1[0] = 8.2;
notele1[1] = 1;
notele1[2] = 10;
notele1[3] = 7.1;
notele1[4] = 6;
double notaproiectului1 = 10;
studentul[1].setstudent(numele1);
studentul[1].setactivitatestudent(notele1, numaruldenote1);
studentul[1].setproiectstudent(numeleproiect1, notaproiectului1);
contor++;
int paginaurm = 0;
cout << "Gestionarea scolaritatii\n";
while (ok == 1) {
switch (paginaurm)
{
case 0:
cout << "\n-------------------------------------------------\nPagina studentilor\n-------------------------------------------------\n1-Adaugare student\n2-Afisare student\n3-Calculare medie finala\n4-Lista studenti introdusi\n5-Lista proiecte realizate\n6-Adaugare student prin copierea datelor altuia\n7-Copiere a datelor unui student pentru altul\n8-Lista medii studenti\n9-Pagina urmatoare\n0-Iesire program\n";
cin >> a;
switch (a)
{
case 1:
cout << "Introduce datele studentului\n-------------------------------------------------\n";
cin >> studentul[contor];
contor++;
paginaurm = 0;
break;
case 2:
cout << "Introduce codul studentului: ";
int k;
cin >> k;
cout << "-------------------------------------------------\n";
cout << studentul[k];
paginaurm = 0;
break;
case 3:
paginaurm = 0;
cout << "Codul studentului pentru care vrei sa afli media: ";
int j;
cin >> j;
if (studentul[j].getstudent() != nullptr) {
cout << "Vrei sa folosesti ponderile de la ultima medie calculata?\n1-DA\n0-NU\n";
bool raspuns;
cin >> raspuns;
if (raspuns == 0) {
cout << "Ce tipe de pondere vei folosi?\nPentru pondere de tip 0-100% apasa 0\nPentru pondere de tip 0-1 apasa 1\n";
bool tip;
cin >> tip;
tipcopie = tip;
if (tip == 0) {
int pondereac, ponderepr;
cout << "Introduce ponderile: ";
cin >> pondereac >> ponderepr;
ac = pondereac;
pr = ponderepr;
medie_finala medie(studentul[j].getmediestudent(), studentul[j].getnotaproiectstudent());
medie.mediecupondere(pondereac, ponderepr);
medii[j] = medie.calcul();
cout << "Media studentului " << studentul[j].getstudent() << " este: " << medii[j] << "\n";
}
else {
double pondereac, ponderepr;
cout << "Introduce ponderile: ";
cin >> pondereac >> ponderepr;
ac1 = pondereac;
pr1 = ponderepr;
medie_finala medie(studentul[j].getmediestudent(), studentul[j].getnotaproiectstudent());
medie.mediecupondere(pondereac, ponderepr);
medii[j] = medie.calcul();
cout << "Media studentului " << studentul[j].getstudent() << " este: " << medii[j] << "\n";
}
}
else
{
if (tipcopie != -1) {
if (raspuns == 1 && tipcopie == 1)
{
medie_finala medie(studentul[j].getmediestudent(), studentul[j].getnotaproiectstudent());
medie.mediecupondere(ac1, pr1);
medii[j] = medie.calcul();
cout << "Media studentului " << studentul[j].getstudent() << " este: " << medii[j] << "\n";
}
else
{
medie_finala medie(studentul[j].getmediestudent(), studentul[j].getnotaproiectstudent());
medie.mediecupondere(ac, pr);
medii[j] = medie.calcul();
cout << "Media studentului " << studentul[j].getstudent() << " este: " << medii[j] << "\n";
}
}
else
{
cout << "E prima medie pe care o calculezi!\n-------------------------------------------------\n";
cout << "Ce tipe de pondere vei folosi?\nPentru pondere de tip 0-100% apasa 0\nPentru pondere de tip 0-1 apasa 1\n";
bool tip;
cin >> tip;
tipcopie = tip;
if (tip == 0) {
int pondereac, ponderepr;
cout << "Introduce ponderile: ";
cin >> pondereac >> ponderepr;
ac = pondereac;
pr = ponderepr;
medie_finala medie(studentul[j].getmediestudent(), studentul[j].getnotaproiectstudent());
medie.mediecupondere(pondereac, ponderepr);
medii[j] = medie.calcul();
cout << "Media studentului " << studentul[j].getstudent() << " este: " << medii[j] << "\n";
}
else {
double pondereac, ponderepr;
cout << "Introduce ponderile: ";
cin >> pondereac >> ponderepr;
ac1 = pondereac;
pr1 = ponderepr;
medie_finala medie(studentul[j].getmediestudent(), studentul[j].getnotaproiectstudent());
medie.mediecupondere(pondereac, ponderepr);
medii[j] = medie.calcul();
cout << "Media studentului " << studentul[j].getstudent() << " este: " << medii[j] << "\n";
}
}
}
}
else
cout << "Nu exista studentul\n";
break;
case 4:
paginaurm = 0;
cout << "Studentii introdusi pana acum\n-------------------------------------------------\n";
for (int i = 0; i < contor; i++)
cout << "Cod " << i << ": Studentul " << studentul[i].getstudent() << "\n";
break;
case 5:
paginaurm = 0;
cout << "Lista cu proiectele realizate\n-------------------------------------------------\n";
for (int i = 0; i < contor; i++)
cout << "Proiectul \"" << studentul[i].getproiectstudent() << "\" realizat de " << studentul[i].getstudent() << "\n";
break;
case 6:
paginaurm = 0;
cout << "Introduce codul studentului pe care vrei sa il creezi prin copiere de date: ";
int cod;
cin >> cod;
if (studentul[cod].getstudent() != nullptr) {
studentul[contor] = studentul[cod];
medii[contor] = medii[cod];
contor++;
}
else
cout << "Cod invalid\n";
break;
case 7:
paginaurm = 0;
cout << "Introduce codul studentului ale carui date vrei sa le copiez,respectiv al caruia ii vei desemna datele\n";
int cod1, cod2;
cin >> cod1 >> cod2;
if (studentul[cod1].getstudent() != nullptr and studentul[cod2].getstudent() != nullptr) {
studentul[cod2] = studentul[cod1];
medii[cod2] = medii[cod1];
}
else
cout << "Cod invalid\n";
break;
case 8:
paginaurm = 0;
cout << "Lista cu mediile\n-------------------------------------------------\n";
for (int i = 0; i < contor; i++) {
if (medii[i] != 0)
cout << studentul[i].getstudent() << " - Media " << medii[i] << "\n";
}
break;
case 9:
paginaurm = 1;
break;
case 0:
ok = 0;
break;
default:
break;
}
break;
case 1:
{
cout << "\n-------------------------------------------------\nPagina profesorilor\n-------------------------------------------------\n1-Adaugare profesor\n2-Afisare lista profesori\n3-Creare anunt\n4-Lista anunturi\n5-Planificare conferinta\n6-Lista conferinte\n7-Data conferinta\n9-Pagina precedenta\n0-Iesire program\n";
int b;
cin >> b;
switch (b) {
case 1:
cin >> profesorul[profesor::numar_prof()];
profesor::incrementare_prof();
break;
case 2:
cout << "Lista cu profesorii\n-------------------------------------------------\n";
for (int i = 0; i < profesor::numar_prof(); i++) {
profesorul[i].afisare_prof();
}
break;
case 3:
{
cout << "Ce tip de anunt vrei sa creezi?\nUzual - 0\nImportant - 1\nExtrem de important - 2\nReclama - 3\n";
int alegere;
cin >> alegere;
string text;
cout << "Textul din anunt:";
cin.ignore();
getline(cin, text);
decidere_tip* p_decidere=new decidere_tip(alegere);
anuntul.push_back(p_decidere->getanunt());
anuntul[size(anuntul) - 1]->set_text(text);
}
case 4: {
cout << "Lista anunturilor\n-------------------------------------------------\n";
for (int i = 0; i < anuntul.size(); i++) {
anuntul[i]->afisare_anunt();
}
break;
}
case 5: {
cin >> conf[contor_conf];
contor_conf++;
break;
}
case 6: {
cout << "Lista conferinte\n-------------------------------------------------\n";
for (int i = 0; i < contor_conf; i++)
{
cout << "Conferinta numarul " << i << ": ";
conf[i].afisareconferinta();
}
break;
}
case 7: {
cout << "Introdu numarul conferintei:\n";
int numar_conferinta;
cin >> numar_conferinta;
data_conf* data1 = &conf[numar_conferinta];
conferinta* cf = dynamic_cast<conferinta*>(data1);
if (cf != nullptr)
{
cout << cf->afisare_data_conf();
cout << "\n";
}
else
cout << 1;
break;
}
case 0:
ok = 0;
break;
case 9:
paginaurm = 0;
}
break;
}
default:
break;
}
}
}