-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathColocviu132019.cpp
731 lines (636 loc) · 20.5 KB
/
Colocviu132019.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
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
#include <iostream>
#include <vector>
#include <cstring>
using namespace std;
class Bilet
{
protected:
static int index;
int stPlecare, stSosire;
int zi, luna, an;
int ora, minut;
int codTren, durata, distanta;
float pret;
int cod;
public:
Bilet(int _sp = 0, int _ss = 0, int _z = 0, int _l = 0, int _a = 0, int _h = 0, int _m = 0, int _c = 0, int _du = 0, int _di = 0, float _p = 0) :
stPlecare(_sp), stSosire(_ss), zi(_z), luna(_l), an(_a), ora(_h), minut(_m), codTren(_c), durata(_du), distanta(_di), pret(_p) {
index++; cod = index;
}
static inline int getIndex() { return index; }
inline int getCodTren() const { return codTren; }
inline int getDistanta() const { return distanta; }
virtual string getSerie() = 0;
virtual void setPret() = 0;
virtual void citire(istream& in);
virtual void afisare(ostream& out) const;
friend istream& operator >> (istream& in, Bilet& b);
friend ostream& operator << (ostream& out, const Bilet& b);
};
int Bilet::index = 0;
void Bilet::citire(istream& in)
{
cout << "Introduceti urmatoarele date: \n";
cout << "Statie plecare: ";
in >> stPlecare;
cout << "Statie sosire: ";
in >> stSosire;
cout << "Data plecarii (zi/luna/an): ";
in >> zi >> luna >> an;
cout << "Ora plecarii: ";
in >> ora >> minut;
cout << "Cod tren: ";
in >> codTren;
cout << "Durata calatorie: ";
in >> durata;
cout << "Distanta calatorie: ";
in >> distanta;
}
/*istream& operator >> (istream& in, Bilet& b)
{
b.citire(in);
return in;
}*/
void Bilet::afisare(ostream& out) const
{
out << "Date bilet: \n";
out << "Statie plecare: " << stPlecare << '\n';
out << "Statie sosire: " << stSosire << '\n';
out << "Data plecarii (zi/luna/an): " << zi << " " << luna << " " << an << '\n';
out << "Ora plecarii: " << ora << " " << minut << '\n';
out << "Cod tren: " << codTren << '\n';
out << "Durata calatorie: " << durata << '\n';
out << "Distanta calatorie: " << distanta << '\n';
}
/*ostream& operator << (ostream& out, const Bilet& b)
{
b.afisare(out);
return out;
}
*/
///////////
class BiletRegio : virtual public Bilet
{
public:
BiletRegio(int _sp = 0, int _ss = 0, int _z = 0, int _l = 0, int _a = 0, int _h = 0, int _m = 0, int _c = 0, int _du = 0, int _di = 0, float _p = 0) :
Bilet(_sp, _ss, _z, _l, _a, _h, _m, _c, _du, _di, _p) {}
};
///////////
class BiletInterRegio : virtual public Bilet
{
protected:
int loc;
public:
BiletInterRegio(int _sp = 0, int _ss = 0, int _z = 0, int _l = 0, int _a = 0, int _h = 0, int _m = 0, int _c = 0, int _du = 0, int _di = 0, float _p = 0, int _lo = 0) :
Bilet(_sp, _ss, _z, _l, _a, _h, _m, _c, _du, _di, _p), loc(_lo) {}
};
///////////
class Bilet1 : virtual public Bilet
{
protected:
string meniu;
public:
Bilet1(int _sp = 0, int _ss = 0, int _z = 0, int _l = 0, int _a = 0, int _h = 0, int _m = 0, int _c = 0, int _du = 0, int _di = 0, float _p = 0, string _me = "") :
Bilet(_sp, _ss, _z, _l, _a, _h, _m, _c, _du, _di, _p), meniu(_me) {}
};
///////////
class Bilet2 : virtual public Bilet
{
public:
Bilet2(int _sp = 0, int _ss = 0, int _z = 0, int _l = 0, int _a = 0, int _h = 0, int _m = 0, int _c = 0, int _du = 0, int _di = 0, float _p = 0) :
Bilet(_sp, _ss, _z, _l, _a, _h, _m, _c, _du, _di, _p) {}
};
///////////
class BiletRegio1 : public BiletRegio, public Bilet1
{
public:
BiletRegio1(int _sp = 0, int _ss = 0, int _z = 0, int _l = 0, int _a = 0, int _h = 0, int _m = 0, int _c = 0, int _du = 0, int _di = 0, float _p = 0, string _me = "") :
BiletRegio(_sp, _ss, _z, _l, _a, _h, _m, _c, _du, _di, _p), Bilet1(_sp, _ss, _z, _l, _a, _h, _m, _c, _du, _di, _p, _me) {}
string inline getSerie() { return "RI-" + cod; }
void setPret() { pret = 0.39 * distanta; pret += pret / 5; }
void citire(istream& in);
void afisare(ostream& out) const;
//friend istream& operator >> (istream& in, BiletRegio1& p);
//friend ostream& operator << (ostream& out, const BiletRegio1& p);
};
void BiletRegio1::citire(istream& in)
{
Bilet::citire(in);
cout << "Meniu: ";
in >> meniu;
}
/*istream& operator >> (istream& in, BiletRegio1& b)
{
b.citire(in);
return in;
}
*/
void BiletRegio1::afisare(ostream& out) const
{
Bilet::afisare(out);
out << "Meniu: " << meniu << '\n';
}
/*
ostream& operator << (ostream& out, const BiletRegio1& b)
{
b.afisare(out);
return out;
}*/
///////////
class BiletRegio2 : public BiletRegio, public Bilet2
{
public:
BiletRegio2(int _sp = 0, int _ss = 0, int _z = 0, int _l = 0, int _a = 0, int _h = 0, int _m = 0, int _c = 0, int _du = 0, int _di = 0, float _p = 0) :
BiletRegio(_sp, _ss, _z, _l, _a, _h, _m, _c, _du, _di, _p), Bilet2(_sp, _ss, _z, _l, _a, _h, _m, _c, _du, _di, _p) {}
string inline getSerie() { return "RII-" + cod; }
void setPret() { pret = 0.39 * distanta; }
void citire(istream& in);
void afisare(ostream& out) const;
//friend istream& operator >> (istream& in, BiletRegio2& p);
//friend ostream& operator << (ostream& out, const BiletRegio2& p);
};
void BiletRegio2::citire(istream& in)
{
Bilet::citire(in);
}
/*istream& operator >> (istream& in, BiletRegio2& b)
{
b.citire(in);
return in;
}*/
void BiletRegio2::afisare(ostream& out) const
{
Bilet::afisare(out);
}
/*ostream& operator << (ostream& out, const BiletRegio2& b)
{
b.afisare(out);
return out;
}*/
///////////
class BiletInterRegio1 : public BiletInterRegio, public Bilet1
{
public:
BiletInterRegio1(int _sp = 0, int _ss = 0, int _z = 0, int _l = 0, int _a = 0, int _h = 0, int _m = 0, int _c = 0, int _du = 0, int _di = 0, float _p = 0, int _lo = 0, string _me = "") :
BiletInterRegio(_sp, _ss, _z, _l, _a, _h, _m, _c, _du, _di, _p, _lo), Bilet1(_sp, _ss, _z, _l, _a, _h, _m, _c, _du, _di, _p, _me) {}
string inline getSerie() { return "IRI-" + cod; }
void setPret() { pret = 0.7 * distanta; pret += pret / 5; }
void citire(istream& in);
void afisare(ostream& out) const;
// friend istream& operator >> (istream& in, BiletInterRegio1& p);
// friend ostream& operator << (ostream& out, const BiletInterRegio1& p);
};
void BiletInterRegio1::citire(istream& in)
{
Bilet::citire(in);
cout << "Meniu: ";
in >> meniu;
cout << "Loc: ";
in >> loc;
}
/*istream& operator >> (istream& in, BiletInterRegio1& b)
{
b.citire(in);
return in;
}*/
void BiletInterRegio1::afisare(ostream& out) const
{
Bilet::afisare(out);
out << "Meniu: " << meniu << '\n';
out << "Loc: " << loc << '\n';
}
/*ostream& operator << (ostream& out, const BiletInterRegio1& b)
{
b.afisare(out);
return out;
}*/
///////////
class BiletInterRegio2 : public BiletInterRegio, public Bilet2
{
public:
BiletInterRegio2(int _sp = 0, int _ss = 0, int _z = 0, int _l = 0, int _a = 0, int _h = 0, int _m = 0, int _c = 0, int _du = 0, int _di = 0, float _p = 0, int _lo = 0) :
BiletInterRegio(_sp, _ss, _z, _l, _a, _h, _m, _c, _du, _di, _p, _lo), Bilet2(_sp, _ss, _z, _l, _a, _h, _m, _c, _du, _di, _p) {}
string inline getSerie() { return "IRII-" + cod; }
void setPret() { pret = 0.7 * distanta; }
void citire(istream& in);
void afisare(ostream& out) const;
//friend istream& operator >> (istream& in, BiletInterRegio2& p);
//friend ostream& operator << (ostream& out, const BiletInterRegio2& p);
};
void BiletInterRegio2::citire(istream& in)
{
Bilet::citire(in);
cout << "Loc: ";
in >> loc;
}
/*istream& operator >> (istream& in, BiletInterRegio2& b)
{
b.citire(in);
return in;
}*/
void BiletInterRegio2::afisare(ostream& out) const
{
Bilet::afisare(out);
out << "Loc: " << loc << '\n';
}
/*ostream& operator << (ostream& out, const BiletInterRegio2& b)
{
b.afisare(out);
return out;
}*/
///////////
class Manager
{
private:
static Manager* instance;
Manager() {}
Manager(const Manager&) = delete;
Manager& operator=(const Manager&) = delete;
vector<Bilet*> bilete;
public:
static Manager* getInstance();
void adaugareBilet();
void afisareBileteTren();
void afisareBileteDistanta();
void anulareBilet();
void freeBilete();
~Manager();
};
Manager* Manager::instance = nullptr;
Manager* Manager::getInstance()
{
if (instance == nullptr)
{
instance = new Manager();
}
return instance;
}
void Manager::adaugareBilet()
{
string s;
Bilet* b = nullptr;
cout << "Introdu tip bilet: ";
cin >> s;
if (s == "Regio1")
b = new BiletRegio1;
else if (s == "Regio2")
b = new BiletRegio2;
else if (s == "InterRegio1")
b = new BiletInterRegio1;
else if (s == "InterRegio2")
b = new BiletInterRegio2;
cin >> (*b);
bilete.push_back(b);
}
void Manager::afisareBileteTren()
{
int cod, i;
cout << "Introduceti cod tren: ";
cin >> cod;
for (i = 0; i < bilete.size(); i++)
if (bilete[i]->getCodTren() == cod)
cout << *(bilete[i]);
}
void Manager::afisareBileteDistanta()
{
int distanta, i;
cout << "Introduceti distanta: ";
cin >> distanta;
for (i = 0; i < bilete.size(); i++)
if (bilete[i]->getDistanta() > distanta)
cout << *(bilete[i]);
}
void Manager::anulareBilet()
{
int i;
string serie;
cout << "Introduceti serie bilet: ";
cin >> serie;
for (i = 0; i < bilete.size(); i++)
if (bilete[i]->getSerie() == serie)
bilete.erase(bilete.begin() + i);
}
void Manager::freeBilete()
{
if (bilete.size() != 0)
{
for (int i = 0; i < bilete.size(); i++)
delete bilete[i];
bilete.clear();
}
}
Manager::~Manager()
{
freeBilete();
}
int main()
{
int cereri, i, cerere;
Manager* M = M->getInstance();
cout << "Introduceti numar cereri: ";
cin >> cereri;
cout << "Optiuni: \n 1. Eliberare bilet nou \n 2. Listare bilete dupa cod tren \n 3. Listare bilete mai mare decat o distanta \n 4. Anulare bilet\n";
for (i = 0; i < cereri; i++)
{
cout << "Introduceti cerere: ";
cin >> cerere;
if (cerere == 1)
M->adaugareBilet();
else if (cerere == 2)
M->afisareBileteTren();
else if (cerere == 3)
M->afisareBileteDistanta();
else if (cerere == 4)
M->anulareBilet();
else cout << "Tasta gresita";
}
return 0;
}
/*
#include <iostream>
#include <cstring>
#include <vector>
using namespace std;
class Bilet
{
protected:
static int nr;
string statie_plecare, statie_sosire;
int zi, luna, an;
int ora, minut;
int cod_tren, durata, dist;
bool anulat;
int cod;
public:
Bilet(string _s_p = "", string _s_s = "", int _zi = 0, int _luna = 0, int _an = 0, int _ora = 0, int _minut = 0, int _c_t = 0, int _durata = 0, int _dist = 0)
: statie_plecare(_s_p), statie_sosire(_s_s), zi(_zi), luna(_luna), an(_an), ora(_ora), minut(_minut),
cod_tren(_c_t), durata(_durata), dist(_dist)
{
anulat = 0;
nr++;
cod = nr;
}
virtual string getSerie() = 0;
void anuleaza() { anulat = 1; }
bool valabil() const { return !anulat; }
int getCodTren() const { return cod_tren; }
int getDist() const { return dist; }
virtual void read(istream& in)
{
in >> statie_plecare;
in >> statie_sosire;
in >> zi >> luna >> an;
in >> ora >> minut;
in >> cod_tren >> durata >> dist;
}
virtual void print(ostream& out)
{
out << "Statia de plecare: " << statie_plecare << "\nStatie sosire: " << statie_sosire;
out << "\nData [zi luna an ora minut]: " << zi << luna << an << ora << minut;
out << "\nCod tren: " << cod_tren << "Durata: " << durata << "Distanta: " << dist;
out << '\n';
}
friend istream& operator >>(istream& in, Bilet& bilet)
{
bilet.read(in);
return in;
}
friend ostream& operator <<(ostream& out, Bilet& bilet)
{
bilet.print(out);
return out;
}
virtual ~Bilet() {}
};
int Bilet::nr = 0;
class BiletInter : virtual public Bilet
{
protected:
int loc_rezervat;
public:
BiletInter(string _s_p = "", string _s_s = "", int _zi = 0, int _luna = 0, int _an = 0, int _ora = 0, int _minut = 0, int _c_t = 0, int _durata = 0, int _dist = 0, int _l_r = 0)
: Bilet(_s_p, _s_s, _zi, _luna, _an, _ora, _minut, _c_t, _durata, _dist),
loc_rezervat(_l_r) {}
virtual ~BiletInter() {}
};
class BiletRegio : virtual public Bilet
{
public:
BiletRegio(string _s_p = "", string _s_s = "", int _zi = 0, int _luna = 0, int _an = 0, int _ora = 0, int _minut = 0, int _c_t = 0, int _durata = 0, int _dist = 0)
: Bilet(_s_p, _s_s, _zi, _luna, _an, _ora, _minut, _c_t, _durata, _dist) {}
virtual ~BiletRegio() {}
};
class BiletClsI : virtual public Bilet
{
protected:
string meniu;
public:
BiletClsI(string _s_p = "", string _s_s = "", int _zi = 0, int _luna = 0, int _an = 0, int _ora = 0, int _minut = 0, int _c_t = 0, int _durata = 0, int _dist = 0, string _meniu = "")
: Bilet(_s_p, _s_s, _zi, _luna, _an, _ora, _minut, _c_t, _durata, _dist),
meniu(_meniu) {}
virtual ~BiletClsI() {}
};
class BiletClsII : virtual public Bilet
{
public:
BiletClsII(string _s_p = "", string _s_s = "", int _zi = 0, int _luna = 0, int _an = 0, int _ora = 0, int _minut = 0, int _c_t = 0, int _durata = 0, int _dist = 0)
: Bilet(_s_p, _s_s, _zi, _luna, _an, _ora, _minut, _c_t, _durata, _dist) {}
virtual ~BiletClsII() {}
};
class BiletRegioClsI : public BiletClsI, public BiletRegio
{
public:
BiletRegioClsI(string _s_p = "", string _s_s = "", int _zi = 0, int _luna = 0, int _an = 0, int _ora = 0, int _minut = 0, int _c_t = 0, int _durata = 0, int _dist = 0, string _meniu = "")
: Bilet(_s_p, _s_s, _zi, _luna, _an, _ora, _minut, _c_t, _durata, _dist), /// asta trebuie?
BiletRegio(_s_p, _s_s, _zi, _luna, _an, _ora, _minut, _c_t, _durata, _dist),
BiletClsI(_s_p, _s_s, _zi, _luna, _an, _ora, _minut, _c_t, _durata, _dist, _meniu) {}
string getSerie()
{
string aux = "RI-" + cod;
return aux;
}
void read(istream& in)
{
Bilet::read(in);
in >> meniu;
}
void print(ostream& out)
{
Bilet::print(out);
out << "Meniu: " << meniu;
out << "\nPret: " << double(0.39*dist + 0.2*0.39*dist);
out << '\n';
}
};
class BiletRegioClsII : public BiletClsII, public BiletRegio
{
public:
BiletRegioClsII(string _s_p = "", string _s_s = "", int _zi = 0, int _luna = 0, int _an = 0, int _ora = 0, int _minut = 0, int _c_t = 0, int _durata = 0, int _dist = 0)
: Bilet(_s_p, _s_s, _zi, _luna, _an, _ora, _minut, _c_t, _durata, _dist),
BiletRegio(_s_p, _s_s, _zi, _luna, _an, _ora, _minut, _c_t, _durata, _dist),
BiletClsII(_s_p, _s_s, _zi, _luna, _an, _ora, _minut, _c_t, _durata, _dist) {}
string getSerie()
{
string aux = "RII-" + cod;
return aux;
}
void read(istream& in)
{
Bilet::read(in);
}
void print(ostream& out)
{
Bilet::print(out);
out << "\nPret: " << double(0.39 * dist + 0.2);
}
};
class BiletInterClsI : public BiletClsI, public BiletInter
{
public:
BiletInterClsI(string _s_p = "", string _s_s = "", int _zi = 0, int _luna = 0, int _an = 0, int _ora = 0, int _minut = 0, int _c_t = 0, int _durata = 0, int _dist = 0, int _l_r = 0, string _meniu = "")
: Bilet(_s_p, _s_s, _zi, _luna, _an, _ora, _minut, _c_t, _durata, _dist),
BiletInter(_s_p, _s_s, _zi, _luna, _an, _ora, _minut, _c_t, _durata, _dist, _l_r),
BiletClsI(_s_p, _s_s, _zi, _luna, _an, _ora, _minut, _c_t, _durata, _dist, _meniu) {}
string getSerie()
{
string aux = "IRI-" + cod;
return aux;
}
void read(istream& in)
{
Bilet::read(in);
in >> loc_rezervat;
in >> meniu;
}
void print(ostream& out)
{
Bilet::print(out);
out << "Loc rezervat: " << loc_rezervat;
out << "\nMeniu: " << meniu;
out << "\nPret: " << double(0.7 * dist + 0.2 * 0.7 * dist);
out << '\n';
}
};
class BiletInterClsII : public BiletClsII, public BiletInter
{
public:
BiletInterClsII(string _s_p = "", string _s_s = "", int _zi = 0, int _luna = 0, int _an = 0, int _ora = 0, int _minut = 0, int _c_t = 0, int _durata = 0, int _dist = 0, int _l_r = 0)
: Bilet(_s_p, _s_s, _zi, _luna, _an, _ora, _minut, _c_t, _durata, _dist),
BiletInter(_s_p, _s_s, _zi, _luna, _an, _ora, _minut, _c_t, _durata, _dist, _l_r),
BiletClsII(_s_p, _s_s, _zi, _luna, _an, _ora, _minut, _c_t, _durata, _dist) {}
string getSerie()
{
string aux = "IRII-" + cod;
return aux;
}
void read(istream& in)
{
Bilet::read(in);
cin >> loc_rezervat;
}
void print(ostream& out)
{
Bilet::print(out);
cout << "Loc rezervat: " << loc_rezervat;
cout << "\nPret: " << double(0.7 * dist);
cout << '\n';
}
};
class Manager //singleton
{
vector <Bilet*> bilete;
static Manager* instance;
Manager() {}
public:
static Manager* getInstance() {
if (instance == nullptr) instance = new Manager();
return instance;
}
void adaugaBilet(string tip, int cls);
void afisBiletTren(int);
void afisBiletDist(int);
void anuleaza(string);
~Manager()
{
for (int i = 0; i < bilete.size(); ++i) delete bilete[i];
bilete.clear();
}
};
Manager* Manager::instance = nullptr;
void Manager::adaugaBilet(string tip, int cls)
{
Bilet* b = nullptr;
if (tip == "regio" && cls == 1) b = new BiletRegioClsI;
if (tip == "regio" && cls == 2) b = new BiletRegioClsII;
if (tip == "inter" && cls == 1) b = new BiletInterClsI;
if (tip == "inter" && cls == 2) b = new BiletInterClsII;
cin >> (*b);
bilete.push_back(b);
}
void Manager::afisBiletTren(int cod)
{
for (int i = 0; i < bilete.size(); ++i)
if (bilete[i]->getCodTren() == cod && bilete[i]->valabil()) cout << *(bilete[i]);
}
void Manager::afisBiletDist(int distanta)
{
for (int i = 0; i < bilete.size(); ++i)
if (bilete[i]->getDist() >= distanta && bilete[i]->valabil()) cout << *(bilete[i]);
}
void Manager::anuleaza(string seria)
{
for (int i = 0; i < bilete.size(); ++i)
if (bilete[i]->getSerie() == seria) bilete[i]->anuleaza();
}
int main()
{
Manager* M = M->getInstance();
int var;
while (1)
{
cout << "1.Elibereaza bilet\n";
cout << "2.Lista biletelor eliberate pentru un tren\n";
cout << "3.Bilete eliberate pentru o distanta data\n";
cout << "4.Anulare bilet.\n";
cout << "5.Inchide\n";
cin >> var;
if (var == 1)
{
string tip;
int cls;
cout << "Tip: regio sau inter ?\n";
cin >> tip;
cout << "\nClasa: 1 sau 2 ?\n";
cin >> cls; cout << '\n';
//Manager::getInstance()->adaugaBilet(tip, cls);
M->adaugaBilet(tip, cls);
}
else if (var == 2)
{
int cod;
cout << "Codul trenului: ";
cin >> cod; cout << '\n';
//Manager::getInstance()->afisBiletTren(cod);
M->afisBiletTren(cod);
}
else if (var == 3)
{
int distanta;
cout << "Distanta: ";
cin >> distanta; cout << '\n';
M->afisBiletDist(distanta);
//Manager::getInstance()->afisBiletDist(distanta);
}
else if (var == 4)
{
string serie;
cout << "Seria: ";
cin >> serie; cout << '\n';
M->anuleaza(serie);
//Manager::getInstance()->anuleaza(serie);
}
else if (var == 5) break;
else cout << "Numar invalid!\n";
}
return 0;
}*/