-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
1475 lines (1198 loc) · 47.7 KB
/
Copy pathmain.cpp
File metadata and controls
1475 lines (1198 loc) · 47.7 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
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include <bits/stdc++.h>
using namespace std;
class Oameni {
public:
Oameni();
Oameni(string);
Oameni(const Oameni &);
void set_nume(string);
int get_id();
string get_nume();
static int generare_id();
friend istream &operator>>(istream &, Oameni &);
friend ostream &operator<<(ostream &, Oameni);
Oameni &operator=(Oameni);
protected:
string nume;
int idOm;
static int ultimulIdGenerat;
};
Oameni::Oameni() {
idOm = generare_id();
}
Oameni::Oameni(string name) {
idOm = generare_id();
this->nume = name;
}
Oameni::Oameni(const Oameni &om) {
this->idOm = om.idOm;
this->nume = om.nume;
}
int Oameni::ultimulIdGenerat = 0;
void Oameni::set_nume(string name) {
this->nume = name;
}
int Oameni::get_id() {
return this->idOm;
}
string Oameni::get_nume() {
return this->nume;
}
int Oameni::generare_id() {
return ultimulIdGenerat++;
}
Oameni &Oameni::operator=(Oameni om) {
this->idOm = om.idOm;
this->nume = om.nume;
return *this;
}
istream &operator>>(istream &citire, Oameni &om) {
citire >> om.nume;
return citire;
}
ostream &operator<<(ostream &afisare, Oameni om) {
afisare << om.idOm << " " << om.nume << "\n";
return afisare;
}
class TehnicaMilitara {
public:
TehnicaMilitara();
TehnicaMilitara(int);
TehnicaMilitara(const TehnicaMilitara &);
virtual ~TehnicaMilitara();
void set_calibru(int);
int get_calibru();
int verificare(int);
friend istream &operator>>(istream &, TehnicaMilitara &);
friend ostream &operator<<(ostream &, TehnicaMilitara &);
TehnicaMilitara &operator=(TehnicaMilitara);
protected:
int calibru;
};
TehnicaMilitara::TehnicaMilitara() {}
TehnicaMilitara::TehnicaMilitara(int valoare) {
this->calibru = valoare;
}
TehnicaMilitara::TehnicaMilitara(const TehnicaMilitara &stoc) {
this->calibru = stoc.calibru;
}
TehnicaMilitara::~TehnicaMilitara() {}
void TehnicaMilitara::set_calibru(int valoare) {
this->calibru = valoare;
}
int TehnicaMilitara::get_calibru() {
return this->calibru;
}
istream &operator>>(istream &citire, TehnicaMilitara &stoc) {
citire >> stoc.calibru;
return citire;
}
ostream &operator<<(ostream &afisare, TehnicaMilitara &stoc) {
afisare << stoc.calibru;
return afisare;
}
TehnicaMilitara &TehnicaMilitara::operator=(TehnicaMilitara stocPrimit) {
this->calibru = stocPrimit.calibru;
return *this;
}
class Arme : public TehnicaMilitara {
public:
Arme();
Arme(int, int, int, int);
Arme(const Arme &);
void set_pistoale(int);
void set_mitraliere(int);
void set_pusti(int);
int get_pistoale();
int get_mitraliere();
int get_pusti();
friend istream &operator>>(istream &, Arme &);
friend ostream &operator<<(ostream &, Arme &);
Arme &operator=(Arme);
Arme operator+(Arme);
Arme operator+=(int);
Arme operator-(Arme);
Arme operator-=(int);
private:
int nrPistoale, nrMitraliere, nrPusti;
};
Arme::Arme() : TehnicaMilitara() {}
Arme::Arme(int calibru, int pistoale, int mitraliere, int pusti) : TehnicaMilitara(calibru) {
this->nrPistoale = pistoale;
this->nrMitraliere = mitraliere;
this->nrPusti = pusti;
}
Arme::Arme(const Arme &arme) : TehnicaMilitara(arme) {
this->nrPistoale = arme.nrPistoale;
this->nrMitraliere = arme.nrMitraliere;
this->nrPusti = arme.nrPusti;
}
void Arme::set_pistoale(int pistoale) {
this->nrPistoale = pistoale;
}
void Arme::set_pusti(int pusti) {
this->nrPusti = pusti;
}
void Arme::set_mitraliere(int mitraliere) {
this->nrMitraliere = mitraliere;
}
int Arme::get_pistoale() {
return this->nrPistoale;
}
int Arme::get_pusti() {
return this->nrPusti;
}
int Arme::get_mitraliere() {
return this->nrMitraliere;
}
istream &operator>>(istream &citire, Arme &arme) {
citire >> arme.calibru >> arme.nrPistoale >> arme.nrMitraliere >> arme.nrPusti;
return citire;
}
ostream &operator<<(ostream &afisare, Arme &arme) {
afisare << arme.calibru << arme.nrPistoale << arme.nrMitraliere << arme.nrPusti;
return afisare;
}
Arme &Arme::operator=(Arme arme) {
this->nrPusti = arme.nrPusti;
this->nrMitraliere = arme.nrMitraliere;
this->nrPistoale = arme.nrPistoale;
return *this;
}
Arme Arme::operator+=(int arm2) {
this->nrPusti = nrPusti + arm2;
this->nrMitraliere = nrMitraliere + arm2;
this->nrPistoale = nrPistoale + arm2;
return *this;
}
Arme Arme::operator+(Arme arm2) {
this->nrPusti += arm2.nrPusti;
this->nrPistoale += arm2.nrPistoale;
this->nrMitraliere += arm2.nrMitraliere;
return *this;
}
Arme Arme::operator-=(int arm2) {
this->nrPusti -= arm2;
this->nrPistoale -= arm2;
this->nrMitraliere -= arm2;
return *this;
}
Arme Arme::operator-(Arme arm2) {
this->nrPusti -= arm2.nrPusti;
this->nrPistoale -= arm2.nrPistoale;
this->nrMitraliere -= arm2.nrMitraliere;
return *this;
}
class Munitie : public TehnicaMilitara {
public:
Munitie();
Munitie(int, int, int, int);
Munitie(const Munitie &);
void set_gloantepistoale(int);
void set_gloantepusti(int);
void set_gloantemitraliere(int);
int get_gloantepistoale();
int get_gloantemitraliere();
int get_gloantepusti();
friend istream &operator>>(istream &stream, Munitie &);
friend ostream &operator<<(ostream &stream, Munitie &);
Munitie operator+=(int mun2);
Munitie operator-=(int mun2);
Munitie operator+(Munitie mun2);
Munitie operator-(Munitie mun2);
private:
int gloantePistoale, gloanteMitraliere, gloantePusti;
};
Munitie::Munitie() {}
Munitie::Munitie(int glPistoale, int glPusti, int glMitraliere, int val) : TehnicaMilitara(val) {
this->gloantePistoale = glPistoale;
this->gloanteMitraliere = glMitraliere;
this->gloantePusti = glPusti;
}
Munitie::Munitie(const Munitie &munitie) : TehnicaMilitara(munitie) {
this->gloantePistoale = munitie.gloantePistoale;
this->gloantePusti = munitie.gloantePusti;
this->gloanteMitraliere = munitie.gloanteMitraliere;
}
void Munitie::set_gloantepistoale(int cant) {
gloantePistoale = cant;
}
void Munitie::set_gloantepusti(int cant) {
gloantePusti = cant;
}
void Munitie::set_gloantemitraliere(int cant) {
gloanteMitraliere = cant;
}
int Munitie::get_gloantepistoale() {
return gloantePistoale;
}
int Munitie::get_gloantemitraliere() {
return gloanteMitraliere;
}
int Munitie::get_gloantepusti() {
return gloantePusti;
}
Munitie Munitie::operator-=(int mun2) {
this->gloantePusti -= mun2;
this->gloanteMitraliere -= mun2;
this->gloantePistoale -= mun2;
return *this;
}
Munitie Munitie::operator-(Munitie mun2) {
this->gloantePusti -= mun2.gloantePusti;
this->gloanteMitraliere -= mun2.gloanteMitraliere;
this->gloantePistoale -= mun2.gloantePistoale;
return *this;
}
Munitie Munitie::operator+(Munitie mun2) {
this->gloantePusti += mun2.gloantePusti;
this->gloanteMitraliere += mun2.gloanteMitraliere;
this->gloantePistoale += mun2.gloantePistoale;
return *this;
}
Munitie Munitie::operator+=(int mun2) {
this->gloantePusti += mun2;
this->gloanteMitraliere += mun2;
this->gloantePistoale += mun2;
return *this;
}
istream &operator>>(istream &citire, Munitie &munitie) {
citire >> munitie.calibru >> munitie.gloantePistoale >> munitie.gloanteMitraliere >> munitie.gloantePusti;
return citire;
}
ostream &operator<<(ostream &afisare, Munitie &munitie) {
afisare << munitie.calibru << " " << munitie.gloantePistoale << " " << munitie.gloanteMitraliere << " "
<< munitie.gloantePusti << "\n";
return afisare;
}
class Coordonate {
public:
Coordonate();
Coordonate(int, int, int);
Coordonate(const Coordonate &);
void set_grade(int);
void set_minute(int);
void set_secunde(int);
int get_grade();
int get_minute();
int get_secunde();
void coord_atac(int, int, int, int);
void determinare_coordonate(float);
friend istream &operator>>(istream &, Coordonate &);
friend ostream &operator<<(ostream &, Coordonate &);
friend bool operator!=(Coordonate, Coordonate);
friend class Decriptare;
friend class Atacuri;
Coordonate &operator=(Coordonate);
private:
int grade, minute, secunde;
};
Coordonate::Coordonate() {}
Coordonate::Coordonate(int gr, int min, int sec) {
this->grade = gr;
this->minute = min;
this->secunde = sec;
}
Coordonate::Coordonate(const Coordonate &coord) {
this->grade = coord.grade;
this->minute = coord.minute;
this->secunde = coord.secunde;
}
void Coordonate::set_grade(int gr) {
this->grade = gr;
}
void Coordonate::set_minute(int min) {
this->minute = min;
}
void Coordonate::set_secunde(int sec) {
this->secunde = sec;
}
int Coordonate::get_grade() {
return this->grade;
}
int Coordonate::get_minute() {
return this->minute;
}
int Coordonate::get_secunde() {
return this->secunde;
}
void Coordonate::determinare_coordonate(float valoare) {
this->grade = int(valoare);
this->minute = int((valoare - this->grade) * 60);
this->secunde = round((valoare - this->grade - this->minute / 60.0) * 3600);
}
void Coordonate::coord_atac(int gr, int min, int sec, int alterare) {
this->grade = gr * alterare;
this->minute = min * alterare + (this->grade);
this->secunde = sec * alterare;
}
bool operator!=(Coordonate coord1, Coordonate coord2) {
if (coord1.grade == coord2.grade)
return false;
if (coord1.minute == coord2.minute)
return false;
if (coord1.secunde == coord2.secunde)
return false;
return true;
}
Coordonate &Coordonate::operator=(Coordonate coord) {
this->grade = coord.grade;
this->minute = coord.minute;
this->secunde = coord.secunde;
return *this;
}
istream &operator>>(istream &stream, Coordonate &coord) {
stream >> coord.grade >> coord.minute >> coord.secunde;
return stream;
}
ostream &operator<<(ostream &stream, Coordonate &coord) {
char grad = 248;
stream << coord.grade << grad << coord.minute << "'" << coord.secunde << "''\n";
return stream;
}
class GestionarArme : public Oameni {
public:
GestionarArme();
GestionarArme(string, string);
GestionarArme(const GestionarArme &);
void set_depozit(string);
string get_depozit();
int suplimentare_stoc(string);
friend istream &operator>>(istream &, GestionarArme &);
friend ostream &operator<<(ostream &, GestionarArme &);
GestionarArme &operator=(GestionarArme);
private:
string numeDepozitArme;
};
GestionarArme::GestionarArme() : Oameni() {
}
GestionarArme::GestionarArme(string name, string depozit) : Oameni(name) {
this->numeDepozitArme = depozit;
}
GestionarArme::GestionarArme(const GestionarArme &depozit) : Oameni(depozit) {
this->numeDepozitArme = depozit.numeDepozitArme;
}
void GestionarArme::set_depozit(string depozit) {
this->numeDepozitArme = depozit;
}
string GestionarArme::get_depozit() {
return this->numeDepozitArme;
}
int GestionarArme::suplimentare_stoc(string mesaj) {
int stoc;
stoc = stoi(mesaj);
return stoc;
}
istream &operator>>(istream &citire, GestionarArme &gestionar) {
citire >> gestionar.nume >> gestionar.numeDepozitArme;
return citire;
}
ostream &operator<<(ostream &afisare, GestionarArme &gestionar) {
afisare << gestionar.idOm << " " << gestionar.nume << " " << gestionar.numeDepozitArme << "\n";
return afisare;
}
GestionarArme &GestionarArme::operator=(GestionarArme depozit) {
this->idOm = depozit.idOm;
this->nume = depozit.nume;
this->numeDepozitArme = depozit.numeDepozitArme;
return *this;
}
class GestionarMunitie : public Oameni {
public:
GestionarMunitie();
GestionarMunitie(string, string);
GestionarMunitie(const GestionarMunitie &);
void set_depozit(string);
string get_depozit();
int suplimentare_stoc(string);
friend istream &operator>>(istream &, GestionarMunitie &);
friend ostream &operator<<(ostream &, GestionarMunitie &);
GestionarMunitie &operator=(GestionarMunitie);
private:
string numeDepozitMunitie;
};
GestionarMunitie::GestionarMunitie() {}
GestionarMunitie::GestionarMunitie(string nume, string depozit) : Oameni(nume) {
this->numeDepozitMunitie = depozit;
}
GestionarMunitie::GestionarMunitie(const GestionarMunitie &gestionar) : Oameni(gestionar) {
this->idOm = gestionar.idOm;
this->numeDepozitMunitie = gestionar.numeDepozitMunitie;
this->nume = gestionar.nume;
}
void GestionarMunitie::set_depozit(string depozit) {
this->numeDepozitMunitie = depozit;
}
string GestionarMunitie::get_depozit() {
return this->numeDepozitMunitie;
}
int GestionarMunitie::suplimentare_stoc(string mesaj) {
int stoc;
stoc = stoi(mesaj);
return stoc;
}
istream &operator>>(istream &citire, GestionarMunitie &gestionar) {
citire >> gestionar.nume >> gestionar.numeDepozitMunitie;
return citire;
}
ostream &operator<<(ostream &afisare, GestionarMunitie &gestionar) {
afisare << gestionar.idOm << " " << gestionar.nume << " " << gestionar.numeDepozitMunitie << "\n";
return afisare;
}
GestionarMunitie &GestionarMunitie::operator=(GestionarMunitie gestionar) {
this->idOm = gestionar.idOm;
this->nume = gestionar.nume;
this->numeDepozitMunitie = gestionar.numeDepozitMunitie;
return *this;
}
class Decriptare {
public:
Decriptare();
Decriptare(string, Oameni, int, Coordonate);
Decriptare(const Decriptare &);
void set_mesaj(string);
void set_id(Oameni);
void set_cheie(int);
string get_mesaj();
Oameni get_id();
int get_cheie();
Coordonate get_coordonate();
int verificare_autenticitate();
void prelucrare_mesaj();
friend istream &operator>>(istream &, Decriptare &);
friend ostream &operator<<(ostream &, Decriptare &);
Decriptare &operator=(Decriptare);
private:
string mesaj;
int cheie;
Oameni idMesager;
Coordonate coordonateMesaj;
};
Decriptare::Decriptare() {}
Decriptare::Decriptare(string msj, Oameni id, int key, Coordonate coord) {
this->mesaj = msj;
this->cheie = key;
this->idMesager = id;
this->coordonateMesaj = coord;
}
Decriptare::Decriptare(const Decriptare &decriptare) {
this->idMesager = decriptare.idMesager;
this->cheie = decriptare.cheie;
this->mesaj = decriptare.mesaj;
this->coordonateMesaj = decriptare.coordonateMesaj;
}
void Decriptare::set_cheie(int key) {
this->cheie = key;
}
void Decriptare::set_id(Oameni om) {
this->idMesager = om;
}
void Decriptare::set_mesaj(string msj) {
this->mesaj = msj;
}
string Decriptare::get_mesaj() {
return this->mesaj;
}
int Decriptare::get_cheie() {
return this->cheie;
}
Oameni Decriptare::get_id() {
return this->idMesager;
}
Coordonate Decriptare::get_coordonate() {
return this->coordonateMesaj;
}
int Decriptare::verificare_autenticitate() {
if (this->idMesager.get_id() < this->cheie)
return 0;
if ((this->idMesager.get_id() - this->cheie) % 2 == 0)
return 0;
if ((this->coordonateMesaj.get_grade() + this->coordonateMesaj.get_minute() + this->coordonateMesaj.get_secunde()) %
2 == 0)
return 0;
return 1;
}
void Decriptare::prelucrare_mesaj() {
int i;
for (i = 0; this->mesaj[i]; i += 1)
this->mesaj[i] = this->mesaj[i] xor this->cheie;
}
Decriptare &Decriptare::operator=(Decriptare decript) {
this->mesaj = decript.mesaj;
this->cheie = decript.cheie;
this->idMesager = decript.idMesager;
this->coordonateMesaj = decript.coordonateMesaj;
return *this;
}
istream &operator>>(istream &citire, Decriptare &decriptare) {
citire.get();
getline(citire, decriptare.mesaj);
citire >> decriptare.cheie;
citire >> decriptare.idMesager;
citire >> decriptare.coordonateMesaj;
return citire;
}
ostream &operator<<(ostream &afisare, Decriptare &decriptare) {
afisare << "idMesager: " << decriptare.idMesager;
afisare << "Mesaj: " << decriptare.mesaj;
afisare << "\nCheie: " << decriptare.cheie;
afisare << "\nCoordonate: " << decriptare.coordonateMesaj << "\n";
return afisare;
}
class Atacuri {
public:
Atacuri();
Atacuri(int, int, int, int, int, Coordonate);
Atacuri(const Atacuri &);
void set_luna(int);
void set_zi(int);
void set_an(int);
void set_ora(int);
void set_km(int);
void set_zona(Coordonate);
int get_luna();
int get_zi();
int get_an();
int get_ora();
int get_km();
Coordonate get_zona();
friend istream &operator>>(istream &, Atacuri &);
friend ostream &operator<<(ostream &, Atacuri &);
bool verificare_siguranta(int, int);
private:
int luna, zi, an, ora, km_de_capitala;
Coordonate zona;
};
Atacuri::Atacuri() {}
Atacuri::Atacuri(int h, int d, int m, int y, int km, Coordonate coord) {
this->ora = h;
this->zi = d;
this->luna = m;
this->an = y;
this->km_de_capitala = km;
this->zona = coord;
}
Atacuri::Atacuri(const Atacuri &atacuri) {
this->zi = atacuri.zi;
this->luna = atacuri.luna;
this->an = atacuri.an;
this->ora = atacuri.ora;
this->km_de_capitala = atacuri.km_de_capitala;
this->zona = atacuri.zona;
}
void Atacuri::set_ora(int h) {
this->ora = h;
}
void Atacuri::set_zi(int d) {
this->zi = d;
}
void Atacuri::set_luna(int m) {
this->luna = m;
}
void Atacuri::set_an(int y) {
this->an = y;
}
void Atacuri::set_km(int km) {
this->km_de_capitala = km;
}
void Atacuri::set_zona(Coordonate coord) {
this->zona = coord;
}
int Atacuri::get_ora() {
return this->ora;
}
int Atacuri::get_zi() {
return this->zi;
}
int Atacuri::get_luna() {
return this->luna;
}
int Atacuri::get_an() {
return this->an;
}
int Atacuri::get_km() {
return this->km_de_capitala;
}
Coordonate Atacuri::get_zona() {
return this->zona;
}
bool Atacuri::verificare_siguranta(int h, int km) {
if (!(h < 8 or h > 20))
return false;
if (km > 100)
return false;
return true;
}
istream &operator>>(istream &citire, Atacuri &atacuri) {
citire >> atacuri.ora >> atacuri.zi >> atacuri.luna >> atacuri.an >> atacuri.zona;
return citire;
}
ostream &operator<<(ostream &afisare, Atacuri &atacuri) {
afisare << "Atacul va avea loc la \nOra: " << atacuri.ora << ":00\nZiua: " << atacuri.zi << "\nLuna: "
<< atacuri.luna
<< "\nAnul: " << atacuri.an << "\nZona de coordonate: " << atacuri.zona << "Atacul are loc la "
<< atacuri.km_de_capitala
<< "km de Paris.\n";
return afisare;
}
class Spion : public Oameni {
public:
Spion();
Spion(string, string);
Spion(const Spion &);
void set_nume(string);
string get_nume();
int aprobare_atac(string);
friend istream &operator>>(istream &, Spion &);
friend ostream &operator<<(ostream &, Spion &);
Spion &operator=(Spion);
private:
string numeDeCod;
};
Spion::Spion() {}
Spion::Spion(string name, string porecla) : Oameni(name) {
this->numeDeCod = porecla;
}
Spion::Spion(const Spion &spion) : Oameni(spion) {
this->numeDeCod = spion.numeDeCod;
}
void Spion::set_nume(string porecla) {
this->numeDeCod = porecla;
}
string Spion::get_nume() {
return this->numeDeCod;
}
int Spion::aprobare_atac(string mesaj) {
Atacuri atac;
Coordonate coord;
char valori[1001], *p;
strcpy(valori, (mesaj).c_str());
p = strtok(valori, "_");
atac.set_ora(atoi(p));
p = strtok(NULL, "_");
atac.set_zi(atoi(p));
p = strtok(NULL, "_");
atac.set_luna(atoi(p));
p = strtok(NULL, "_");
atac.set_an(atoi(p));
p = strtok(NULL, "_");
atac.set_km(atoi(p));
atac.set_zona(coord);
if (atac.verificare_siguranta(atac.get_ora(), atac.get_km()))
return 1;
else
return 0;
}
istream &operator>>(istream &citire, Spion &spion) {
citire >> spion.nume >> spion.numeDeCod;
return citire;
}
ostream &operator<<(ostream &afisare, Spion &spion) {
afisare << spion.idOm << " " << spion.nume << " " << spion.numeDeCod << "\n";
return afisare;
}
Spion &Spion::operator=(Spion spion) {
this->idOm = spion.idOm;
this->nume = spion.nume;
this->numeDeCod = spion.numeDeCod;
return *this;
}
/// Tehnica Militara
/// / \
/// Arme Munitie
int main() {
vector<Decriptare> mesaje;
vector<Arme> depozitArme;
vector<Munitie> depozitMunitie;
vector<TehnicaMilitara *> tehnica;
bool meniu0 = true, meniu1 = true, meniu2 = true, meniu3 = true, meniu4 = true;
int optiune1, optiune2, optiune3, optiune4, index;
string ceva;
while (meniu0) {
cout << "Apasati orice buton pentru a deschide dispozitivul si apasati enter!\n";
cin >> ceva;
cout << "Se deschide dispozitivul. Asteptati.\n";
cout << char(201);
for (index = 0; index < 21; index += 1) {
cout << char(205);
}
cout << char(187) << "\n" << char(186) << " ";
for (index = 0; index < 10; index += 1) {
cout << char(219) << " ";
for (int j = 0; j < 60000000; j += 1);
}
cout << char(186) << " 100%\n" << char(200);
for (index = 0; index < 21; index += 1) {
cout << char(205);
}
cout << char(188) << "\n";
while (meniu1) {
cout