-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
3508 lines (3203 loc) · 148 KB
/
main.cpp
File metadata and controls
3508 lines (3203 loc) · 148 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;
//Base class of the program
class Sports
{
protected:
public:
//Components of Sports common for all 3 sports.
string First_name;
string Last_name;
int Age;
string Team;
string Country;
int Win;
int Lost;
int No_of_matches;
Sports() //Default Constructor
{
First_name = "";
Last_name = "";
Age = 0;
Team = "";
Country = "";
Win = 0;
Lost = 0;
No_of_matches = 0;
}
//Parameterized Constructor
Sports(string first_name, string last_name, int age, string team, string country, int win, int lost, int no_of_matches)
{
First_name = first_name;
Last_name = last_name;
Age = age;
Team = team;
Country = country;
Win = win;
Lost = lost;
No_of_matches = no_of_matches;
}
~Sports() {} //Destructor
void Main_Display()
{
cout << " **********************************" << endl;
cout << " WELCOME TO SPORTS ANALYZER PROGRAM" << endl;
cout << " **********************************" << endl
<< endl
<< endl;
cout << " ";
system("pause");
system("cls");
cout << " **********************************" << endl;
cout << " WELCOME TO SPORTS ANALYZER PROGRAM" << endl;
cout << " **********************************" << endl
<< endl
<< endl;
cout << " Please Choose the Sports by pressing the number next to it : " << endl
<< endl;
cout << " 1) Football" << endl;
cout << " 2) Basketball" << endl;
cout << " 3) Cricket" << endl;
cout << " 0) To exit the program " << endl
<< endl;
cout << " Enter your choice: ";
}
};
//Base class for football ---> Inherited from class "Sports"
class Football : public Sports
{
protected:
public:
string Position;
int Pass_Accuracy;
int Red_card;
int Draw;
Football() //Default Constructor for Football class
{
Position = "";
Pass_Accuracy = 0;
Red_card = 0;
Draw = 0;
}
//Parameterized Constructor for Football class
Football(string first_name, string last_name, int age, string team, string country, int win, int lost, int no_of_matches, string position, int pass_accuracy, int red_card, int draw) : Sports(first_name, last_name, age, team, country, win, lost, no_of_matches)
{
Position = position;
Pass_Accuracy = pass_accuracy;
Red_card = red_card;
Draw = draw;
}
~Football() {} //Deconstructor for Football class
void Display_content_f()
{
cout << " **********************************" << endl;
cout << " WELCOME TO SPORTS ANALYZER PROGRAM" << endl;
cout << " **********************************" << endl
<< endl
<< endl;
cout << " >>>>>> Welcome to Football <<<<<<" << endl
<< endl;
cout << " 1. View Teams " << endl;
cout << " 2. View Players " << endl;
cout << " 3. Stats " << endl;
cout << " 4. Standings " << endl;
cout << " 5. Return to Main Menu" << endl;
cout << " 0. EXIT" << endl
<< endl;
cout << " Enter your choice: ";
}
void Team_display_f() //For diplaying the teams of football
{
fstream team_f("team_f.txt");
string f;
if (!team_f)
cout << "Error" << endl;
else
{
while (!team_f.eof())
{
getline(team_f, f);
cout << f << endl;
}
}
}
void Standings_display_f() //For displaying the standings of football
{
fstream standings_f("standings_f.txt");
string f;
if (!standings_f)
cout << "Error" << endl;
else
{
while (!standings_f.eof())
{
getline(standings_f, f);
cout << f << endl;
}
}
}
};
//Attack class (Inherited from Football class --> Will contain all the components of Football as well as its parent class Sports)
class Attack : public Football
{
protected:
public:
int Goals;
float Shot_accuracy;
int Assist;
Attack() // Default Constructor for Attack class
{
Goals = 0;
Shot_accuracy = 0;
Assist = 0;
}
// Parameterized Constructor for Attack class
Attack(string first_name, string last_name, int age, string team, string country, int win, int lost, string position, int no_of_matches, int assist, int pass_accuracy, int red_card, int draw, int goals, float shot_accurracy) : Football(first_name, last_name, age, team, country, win, lost, no_of_matches, position, pass_accuracy, red_card, draw)
{
Assist = assist;
Goals = goals;
Shot_accuracy = shot_accurracy;
}
~Attack() {} // Destructor for Attack class
void Display_stats_f_a(Attack *A)
{
fstream stats_f_a("attack.txt");
int id[60];
int _id = 1;
for (int i = 0; i < 60; i++)
{
id[i] = _id;
_id++;
}
stats_f_a.seekg(0);
for (int i = 0; i < 58; i++)
{
stats_f_a >> A[i].First_name >> A[i].Last_name >> A[i].Position >> A[i].Age >> A[i].Team >> A[i].Country >> A[i].No_of_matches >> A[i].Goals >> A[i].Shot_accuracy >> A[i].Assist >> A[i].Pass_Accuracy >> A[i].Red_card;
}
cout << "SNO F.Name L.Name Pos AGE TEAM COUNTRY App Goals S.Accu Ass P.Accu RCd" << endl
<< endl
<< endl;
for (int i = 0; i < 58; i++)
{
cout << left << setw(4) << id[i] << setw(10) << A[i].First_name << setw(14) << A[i].Last_name << setw(5) << A[i].Position << setw(4) << A[i].Age << setw(19) << A[i].Team << setw(13) << A[i].Country << setw(5) << A[i].No_of_matches << setw(6) << A[i].Goals << setw(7) << A[i].Shot_accuracy << setw(4) << A[i].Assist << setw(7) << A[i].Pass_Accuracy << setw(3) << A[i].Red_card << endl;
cout << "-----------------------------------------------------------------------------------------------------" << endl;
}
}
void Search_player_f_a(Attack *A, string name)
{
fstream psearch_a("attack.txt");
int id[60];
int _id = 1;
for (int i = 0; i < 60; i++)
{
id[i] = _id;
_id++;
}
psearch_a.seekg(0);
for (int i = 0; i < 58; i++)
{
psearch_a >> A[i].First_name >> A[i].Last_name >> A[i].Position >> A[i].Age >> A[i].Team >> A[i].Country >> A[i].No_of_matches >> A[i].Goals >> A[i].Shot_accuracy >> A[i].Assist >> A[i].Pass_Accuracy >> A[i].Red_card;
}
int check = 0;
for (int i = 0; i < 58; i++)
{
if (name == A[i].First_name || name == A[i].Last_name)
{
check = 1;
}
}
if (check == 1)
{
cout << "SNO F.Name L.Name Pos AGE TEAM COUNTRY App Goals S.Accu Ass P.Accu RCd" << endl
<< endl
<< endl;
}
else
{
cout << "This player does not exist" << endl
<< endl;
}
for (int i = 0; i < 58; i++)
{
if (name == A[i].First_name || name == A[i].Last_name)
{
cout << left << setw(4) << id[i] << setw(10) << A[i].First_name << setw(14) << A[i].Last_name << setw(5) << A[i].Position << setw(4) << A[i].Age << setw(22) << A[i].Team << setw(13) << A[i].Country << setw(5) << A[i].No_of_matches << setw(6) << A[i].Goals << setw(7) << A[i].Shot_accuracy << setw(4) << A[i].Assist << setw(7) << A[i].Pass_Accuracy << setw(3) << A[i].Red_card << endl;
cout << "---------------------------------------------------------------------------------------------------------" << endl;
}
}
}
void Player_display_f_a(Attack *A)
{
fstream player_f_a("attack.txt");
int id[60];
int _id = 1;
for (int i = 0; i < 60; i++)
{
id[i] = _id;
_id++;
}
player_f_a.seekg(0);
for (int i = 0; i < 60; i++)
{
player_f_a >> A[i].First_name >> A[i].Last_name >> A[i].Position >> A[i].Age >> A[i].Team >> A[i].Country >> A[i].No_of_matches >> A[i].Goals >> A[i].Shot_accuracy >> A[i].Assist >> A[i].Pass_Accuracy >> A[i].Red_card;
}
cout << "FORWARD : " << endl
<< endl;
cout << "SNO F.Name L.Name Pos AGE TEAM COUNTRY" << endl
<< endl;
for (int i = 0; i < 45; i++)
{
cout << left << setw(4) << id[i] << setw(10) << A[i].First_name << setw(14) << A[i].Last_name << setw(5) << A[i].Position << setw(4) << A[i].Age << setw(19) << A[i].Team << setw(13) << A[i].Country << endl;
cout << "----------------------------------------------------------------------" << endl;
}
cout << endl;
}
};
//Midfield class (Inherited from Football class --> Will contain all the components of Football as well as its parent class Sports)
class MidField : public Football
{
protected:
public:
int Goals;
float Shot_accuracy;
int Assist;
MidField() //Default Constructor for Midfield class
{
Goals = 0;
Shot_accuracy = 0;
}
//Parameterized Constructor for Midfield class
MidField(string first_name, string last_name, int age, string team, string country, int win, int lost, string position, int no_of_matches, int assist, int pass_accuracy, int red_card, int draw, int goals, float shot_accurracy) : Football(first_name, last_name, age, team, country, win, lost, no_of_matches, position, pass_accuracy, red_card, draw)
{
Goals = goals;
Shot_accuracy = shot_accurracy;
Assist = assist;
}
~MidField() {} //Destructor for Midfield class
void Display_stats_f_m(MidField *Mf)
{
fstream stats_f_m("midfield.txt");
int id[120];
int _id = 1;
for (int i = 0; i < 120; i++)
{
id[i] = _id;
_id++;
}
stats_f_m.seekg(0);
for (int i = 0; i < 111; i++)
{
stats_f_m >> Mf[i].First_name >> Mf[i].Last_name >> Mf[i].Position >> Mf[i].Age >> Mf[i].Team >> Mf[i].Country >> Mf[i].No_of_matches >> Mf[i].Goals >> Mf[i].Shot_accuracy >> Mf[i].Assist >> Mf[i].Pass_Accuracy >> Mf[i].Red_card;
}
cout << "SNO F.Name L.Name Pos AGE TEAM COUNTRY App Goals S.Accu Ass P.Accu RCd" << endl
<< endl
<< endl;
for (int i = 0; i < 111; i++)
{
cout << left << setw(4) << id[i] << setw(10) << Mf[i].First_name << setw(14) << Mf[i].Last_name << setw(5) << Mf[i].Position << setw(4) << Mf[i].Age << setw(22) << Mf[i].Team << setw(13) << Mf[i].Country << setw(5) << Mf[i].No_of_matches << setw(6) << Mf[i].Goals << setw(7) << Mf[i].Shot_accuracy << setw(4) << Mf[i].Assist << setw(7) << Mf[i].Pass_Accuracy << setw(3) << Mf[i].Red_card << endl;
cout << "--------------------------------------------------------------------------------------------------------" << endl;
}
}
void Search_player_f_m(MidField *Mf, string name)
{
fstream psearch_m("midfield.txt");
int id[120];
int _id = 1;
for (int i = 0; i < 120; i++)
{
id[i] = _id;
_id++;
}
psearch_m.seekg(0);
for (int i = 0; i < 111; i++)
{
psearch_m >> Mf[i].First_name >> Mf[i].Last_name >> Mf[i].Position >> Mf[i].Age >> Mf[i].Team >> Mf[i].Country >> Mf[i].No_of_matches >> Mf[i].Goals >> Mf[i].Shot_accuracy >> Mf[i].Assist >> Mf[i].Pass_Accuracy >> Mf[i].Red_card;
}
int check = 0;
for (int i = 0; i < 111; i++)
{
if (name == Mf[i].First_name || name == Mf[i].Last_name)
{
check = 1;
}
}
if (check == 1)
{
cout << "SNO F.Name L.Name Pos AGE TEAM COUNTRY App Goals S.Accu Ass P.Accu RCd" << endl
<< endl
<< endl;
}
else
{
cout << "This player does not exist" << endl
<< endl;
}
for (int i = 0; i < 111; i++)
{
if (name == Mf[i].First_name || name == Mf[i].Last_name)
{
cout << left << setw(4) << id[i] << setw(10) << Mf[i].First_name << setw(14) << Mf[i].Last_name << setw(5) << Mf[i].Position << setw(4) << Mf[i].Age << setw(22) << Mf[i].Team << setw(13) << Mf[i].Country << setw(5) << Mf[i].No_of_matches << setw(6) << Mf[i].Goals << setw(7) << Mf[i].Shot_accuracy << setw(4) << Mf[i].Assist << setw(7) << Mf[i].Pass_Accuracy << setw(3) << Mf[i].Red_card << endl;
cout << "--------------------------------------------------------------------------------------------------------" << endl;
}
}
}
void Player_display_f_m(MidField *Mf)
{
fstream player_f_m("midfield.txt");
int id[120];
int _id = 1;
for (int i = 0; i < 120; i++)
{
id[i] = _id;
_id++;
}
player_f_m.seekg(0);
for (int i = 0; i < 111; i++)
{
player_f_m >> Mf[i].First_name >> Mf[i].Last_name >> Mf[i].Position >> Mf[i].Age >> Mf[i].Team >> Mf[i].Country >> Mf[i].No_of_matches >> Mf[i].Goals >> Mf[i].Shot_accuracy >> Mf[i].Assist >> Mf[i].Pass_Accuracy >> Mf[i].Red_card;
}
cout << "MID-FIELD : " << endl
<< endl;
cout << "SNO F.Name L.Name Pos AGE TEAM COUNTRY" << endl
<< endl;
for (int i = 0; i < 111; i++)
{
cout << left << setw(4) << id[i] << setw(10) << Mf[i].First_name << setw(14) << Mf[i].Last_name << setw(5) << Mf[i].Position << setw(4) << Mf[i].Age << setw(22) << Mf[i].Team << setw(13) << Mf[i].Country << endl;
cout << "-----------------------------------------------------------------------" << endl;
}
cout << endl;
}
};
//Defence class (Inherited from Football class --> Will contain all the components of Football as well as its parent class Sports)
class Defence : public Football
{
protected:
public:
int Goals;
int Tackles_won;
int Clearance;
int Blocked_shots;
int Assist;
Defence() //Default constructor for Defence class
{
Goals = 0;
Tackles_won = 0;
Clearance = 0;
Blocked_shots = 0;
Assist = 0;
}
//Parameterized Constructor for Defence class
Defence(string first_name, string last_name, int age, string team, string country, int win, int lost, string position, int no_of_matches, int assist, int pass_accuracy, int red_card, int draw, int goals, int tackles_won, int clearance, int blocked_shots) : Football(first_name, last_name, age, team, country, win, lost, no_of_matches, position, pass_accuracy, red_card, draw)
{
Goals = goals;
Tackles_won = tackles_won;
Clearance = clearance;
Blocked_shots = blocked_shots;
Assist = assist;
}
~Defence() {} //Destructor for Defence class
void Display_stats_f_d(Defence *D)
{
fstream stats_f_d("DEFENDERS.txt");
if (!stats_f_d)
cout << "Error opening this file!!" << endl;
int id[120];
int _id = 1;
for (int i = 0; i < 120; i++)
{
id[i] = _id;
_id++;
}
stats_f_d.seekg(0);
for (int i = 0; i < 107; i++)
{
stats_f_d >> D[i].First_name >> D[i].Last_name >> D[i].Position >> D[i].Age >> D[i].Team >> D[i].Country >> D[i].No_of_matches >> D[i].Tackles_won >> D[i].Clearance >> D[i].Blocked_shots >> D[i].Red_card >> D[i].Goals >> D[i].Pass_Accuracy;
}
cout << "SNO F.NAME L.NAME POS AGE TEAM COUNTRY APP TACKLE CLEARANCE BLK.SHOT RC Goals P.ACC" << endl
<< endl
<< endl;
for (int i = 0; i < 107; i++)
{
cout << left << setw(4) << id[i] << setw(10) << D[i].First_name << setw(14) << D[i].Last_name << setw(5) << D[i].Position << setw(4) << D[i].Age << setw(22) << D[i].Team << setw(13) << D[i].Country << setw(5) << D[i].No_of_matches << setw(7) << D[i].Tackles_won << setw(10) << D[i].Clearance << setw(9) << D[i].Blocked_shots << setw(3) << D[i].Red_card << setw(6) << D[i].Goals << setw(7) << D[i].Pass_Accuracy << endl;
cout << "---------------------------------------------------------------------------------------------------------------------" << endl;
}
}
void Search_player_f_d(Defence *D, string name)
{
fstream psearch_d("DEFENDERS.txt");
if (!psearch_d)
cout << "Error opening this file!!" << endl;
int id[120];
int _id = 1;
for (int i = 0; i < 120; i++)
{
id[i] = _id;
_id++;
}
psearch_d.seekg(0);
for (int i = 0; i < 107; i++)
{
psearch_d >> D[i].First_name >> D[i].Last_name >> D[i].Position >> D[i].Age >> D[i].Team >> D[i].Country >> D[i].No_of_matches >> D[i].Tackles_won >> D[i].Clearance >> D[i].Blocked_shots >> D[i].Red_card >> D[i].Goals >> D[i].Pass_Accuracy;
}
int check = 0;
for (int i = 0; i < 107; i++)
{
if (name == D[i].First_name || name == D[i].Last_name)
{
check = 1;
}
}
if (check == 1)
{
cout << "F.NAME L.NAME POS AGE TEAM COUNTRY APP TACKLE CLEARANCE BLK.SHOT RC Goals P.ACC" << endl
<< endl
<< endl;
}
else
{
cout << "This player does not exist" << endl
<< endl;
}
for (int i = 0; i < 107; i++)
{
if (name == D[i].First_name || name == D[i].Last_name)
{
cout << left << setw(10) << D[i].First_name << setw(14) << D[i].Last_name << setw(5) << D[i].Position << setw(4) << D[i].Age << setw(22) << D[i].Team << setw(13) << D[i].Country << setw(5) << D[i].No_of_matches << setw(7) << D[i].Tackles_won << setw(10) << D[i].Clearance << setw(9) << D[i].Blocked_shots << setw(3) << D[i].Red_card << setw(6) << D[i].Goals << setw(7) << D[i].Pass_Accuracy << endl;
cout << "------------------------------------------------------------------------------------------------------------------" << endl;
}
}
}
void Player_display_f_d(Defence *D)
{
fstream player_f_d("DEFENDERS.txt");
int id[120];
int _id = 1;
for (int i = 0; i < 120; i++)
{
id[i] = _id;
_id++;
}
player_f_d.seekg(0);
for (int i = 0; i < 107; i++)
{
player_f_d >> D[i].First_name >> D[i].Last_name >> D[i].Position >> D[i].Age >> D[i].Team >> D[i].Country >> D[i].No_of_matches >> D[i].Tackles_won >> D[i].Clearance >> D[i].Blocked_shots >> D[i].Red_card >> D[i].Goals >> D[i].Pass_Accuracy;
}
cout << "DEFENCE : " << endl
<< endl;
cout << "SNO F.Name L.Name Pos AGE TEAM COUNTRY" << endl
<< endl;
for (int i = 0; i < 107; i++)
{
cout << left << setw(4) << id[i] << setw(10) << D[i].First_name << setw(14) << D[i].Last_name << setw(5) << D[i].Position << setw(4) << D[i].Age << setw(22) << D[i].Team << setw(13) << D[i].Country << endl;
cout << "-----------------------------------------------------------------------" << endl;
}
cout << endl;
}
};
//GoalKeeper class (Inherited from Football class --> Will contain all the components of Football as well as its parent class Sports)
class GoalKeeper : public Football
{
protected:
public:
int Clean_sheets;
int Saves_made;
int Goals_conceeded;
GoalKeeper() //Default constructor for Goalkeeper class
{
Clean_sheets = 0;
Saves_made = 0;
Goals_conceeded = 0;
}
//Parameterized Constructor for Goalkeeper class
GoalKeeper(string first_name, string last_name, int age, string team, string country, int win, int lost, string position, int no_of_matches, int assist, int pass_accuracy, int red_card, int draw, int clean_sheets, int saves_made, int goals_conceeded) : Football(first_name, last_name, age, team, country, win, lost, no_of_matches, position, pass_accuracy, red_card, draw)
{
Clean_sheets = clean_sheets;
Saves_made = saves_made;
Goals_conceeded = goals_conceeded;
}
~GoalKeeper() {} //Destructor for Goalkeeper class
void Search_player_f_gk(GoalKeeper *Gk, string name)
{
fstream psearch_gk("gk.txt");
int id[30];
int _id = 1;
for (int i = 0; i < 30; i++)
{
id[i] = _id;
_id++;
}
psearch_gk.seekg(0);
for (int i = 0; i < 27; i++)
{
psearch_gk >> Gk[i].First_name >> Gk[i].Last_name >> Gk[i].Position >> Gk[i].Age >> Gk[i].Team >> Gk[i].Country >> Gk[i].No_of_matches >> Gk[i].Clean_sheets >> Gk[i].Saves_made >> Gk[i].Goals_conceeded >> Gk[i].Red_card;
}
int check = 0;
for (int i = 0; i < 27; i++)
{
if (name == Gk[i].First_name || name == Gk[i].Last_name)
{
check = 1;
}
}
if (check == 1)
{
cout << "SNO F.Name L.Name Pos AGE TEAM COUNTRY App Cln.S Saves G.Con RCd" << endl
<< endl
<< endl;
}
else
{
cout << "This player does not exist" << endl
<< endl;
}
for (int i = 0; i < 27; i++)
{
if (name == Gk[i].First_name || name == Gk[i].Last_name)
{
cout << left << setw(4) << id[i] << setw(10) << Gk[i].First_name << setw(14) << Gk[i].Last_name << setw(5) << Gk[i].Position << setw(4) << Gk[i].Age << setw(22) << Gk[i].Team << setw(13) << Gk[i].Country << setw(5) << Gk[i].No_of_matches << setw(6) << Gk[i].Clean_sheets << setw(6) << Gk[i].Saves_made << setw(6) << Gk[i].Goals_conceeded << setw(3) << Gk[i].Red_card << endl;
cout << "-----------------------------------------------------------------------------------------------------" << endl;
}
}
}
void Player_display_f_gk(GoalKeeper *Gk)
{
fstream player_f_gk("gk.txt");
int id[30];
int _id = 1;
for (int i = 0; i < 30; i++)
{
id[i] = _id;
_id++;
}
player_f_gk.seekg(0);
for (int i = 0; i < 27; i++)
{
player_f_gk >> Gk[i].First_name >> Gk[i].Last_name >> Gk[i].Position >> Gk[i].Age >> Gk[i].Team >> Gk[i].Country >> Gk[i].No_of_matches >> Gk[i].Clean_sheets >> Gk[i].Saves_made >> Gk[i].Goals_conceeded >> Gk[i].Red_card;
}
cout << "GOAL-KEEPERS : " << endl
<< endl;
cout << "SNO F.Name L.Name Pos AGE TEAM COUNTRY" << endl
<< endl;
for (int i = 0; i < 27; i++)
{
cout << left << setw(4) << id[i] << setw(10) << Gk[i].First_name << setw(14) << Gk[i].Last_name << setw(5) << Gk[i].Position << setw(4) << Gk[i].Age << setw(22) << Gk[i].Team << setw(13) << Gk[i].Country << endl;
cout << "-----------------------------------------------------------------------" << endl;
}
cout << endl;
}
void Display_stats_f_gk(GoalKeeper *Gk)
{
fstream stats_f_gk("gk.txt");
int id[30];
int _id = 1;
for (int i = 0; i < 30; i++)
{
id[i] = _id;
_id++;
}
stats_f_gk.seekg(0);
for (int i = 0; i < 27; i++)
{
stats_f_gk >> Gk[i].First_name >> Gk[i].Last_name >> Gk[i].Position >> Gk[i].Age >> Gk[i].Team >> Gk[i].Country >> Gk[i].No_of_matches >> Gk[i].Clean_sheets >> Gk[i].Saves_made >> Gk[i].Goals_conceeded >> Gk[i].Red_card;
}
cout << "SNO F.Name L.Name Pos AGE TEAM COUNTRY App Cln.S Saves G.Con RCd" << endl
<< endl
<< endl;
for (int i = 0; i < 27; i++)
{
cout << left << setw(4) << id[i] << setw(10) << Gk[i].First_name << setw(14) << Gk[i].Last_name << setw(5) << Gk[i].Position << setw(4) << Gk[i].Age << setw(22) << Gk[i].Team << setw(13) << Gk[i].Country << setw(5) << Gk[i].No_of_matches << setw(6) << Gk[i].Clean_sheets << setw(7) << Gk[i].Saves_made << setw(7) << Gk[i].Goals_conceeded << setw(3) << Gk[i].Red_card << endl;
cout << "-----------------------------------------------------------------------------------------------------" << endl;
}
}
};
//Base class for basketball ---> Inherited from class "Sports"
class Basketball : public Sports
{
protected:
string Position;
int Minutes_played;
int Points;
int Assists;
int Rebounds;
int Field_goal_made;
int Field_goal_attempt;
float Field_goal_percentage;
int Three_ptr_made;
int Three_ptr_attempt;
float Three_ptr_percentage;
int Free_throw_made;
int Free_throw_attempt;
float Free_throw_percentage;
int Steals;
int Blocks;
int Turnover;
public:
Basketball() //Default constructor for Basketball class
{
Position = "";
Minutes_played = 0;
Points = 0;
Assists = 0;
Rebounds = 0;
Field_goal_made = 0;
Field_goal_attempt = 0;
Field_goal_percentage = 0;
Three_ptr_made = 0;
Three_ptr_attempt = 0;
Three_ptr_percentage = 0;
Free_throw_made = 0;
Free_throw_attempt = 0;
Free_throw_percentage = 0;
Steals = 0;
Blocks = 0;
Turnover = 0;
}
//Parameterized Constructor for Basketball class
Basketball(string first_name, string last_name, int age, string team, string country, int win, int lost, int no_of_matches, string position, int minutes_played, int points, int assists, int rebounds, int field_goal_made, int field_goal_attempt, float field_goal_percentage, int three_ptr_made, int three_ptr_attempt, float three_ptr_percentage, int free_throw_made, int free_throw_attempt, float free_throw_percentage, int steals, int blocks, int turnover) : Sports(first_name, last_name, age, team, country, win, lost, no_of_matches)
{
Position = position;
Minutes_played = minutes_played;
Points = points;
Assists = assists;
Rebounds = rebounds;
Field_goal_made = field_goal_made;
Field_goal_attempt = field_goal_attempt;
Field_goal_percentage = field_goal_percentage;
Three_ptr_made = three_ptr_made;
Three_ptr_attempt = three_ptr_attempt;
Three_ptr_percentage = three_ptr_percentage;
Free_throw_made = free_throw_made;
Free_throw_attempt = free_throw_attempt;
Free_throw_percentage = free_throw_percentage;
Steals = steals;
Blocks = blocks;
Turnover = turnover;
}
~Basketball() {} //Destructor for Basketball class
void Display_content_b() //Main Display of basketball
{
cout << " **********************************" << endl;
cout << " WELCOME TO SPORTS ANALYZER PROGRAM" << endl;
cout << " **********************************" << endl
<< endl
<< endl;
cout << " >>>> Welcome to Basketball <<<<" << endl
<< endl;
cout << " 1. View Teams " << endl;
cout << " 2. View Players " << endl;
cout << " 3. Stats " << endl;
cout << " 4. Standings " << endl;
cout << " 5. Return to Main Menu" << endl;
cout << " 0. EXIT" << endl
<< endl;
cout << " Enter your Choice: ";
}
void Team_display_b()
{
fstream team_b("team_b.txt"); //Team txt file
string b;
if (!team_b) // if there's an error opening the team file
cout << "Error opening the file!!" << endl;
else
{
while (!team_b.eof()) //reads the file till eof
{
getline(team_b, b);
cout << b << endl;
}
}
}
void Search_player_b(Basketball *B)
{
fstream search_b("basketball_demo.txt");
if (!search_b) // if there's an error opening the team file
cout << "Error opening the file!!" << endl;
int id[400]; // ID allotted to every player
search_b.seekg(0); //makes the pointer start reading from the beginning
for (int i = 0; i < 300; i++) //inputs all the data into class's objects
{
search_b >> id[i] >> B[i].First_name >> B[i].Last_name >> B[i].Age >> B[i].Team >> B[i].Country >> B[i].Position >> B[i].No_of_matches >> B[i].Win >> B[i].Lost >> B[i].Minutes_played >> B[i].Points >> B[i].Assists >> B[i].Rebounds >> B[i].Field_goal_made >> B[i].Field_goal_attempt >> B[i].Field_goal_percentage >> B[i].Three_ptr_made >> B[i].Three_ptr_attempt >> B[i].Three_ptr_percentage >> B[i].Free_throw_made >> B[i].Free_throw_attempt >> B[i].Free_throw_percentage >> B[i].Steals >> B[i].Blocks >> B[i].Turnover;
}
cout << "Enter name of the player to search : ";
string name; // player to be searched
cin >> name;
int check = 0;
for (int i = 0; i < 300; i++)
{
if (name == B[i].First_name || name == B[i].Last_name)
{
check = 1;
}
}
if (check == 1)
{
cout << "F.Name L.Name AGE TEAM COUNTRY POS TM MP PTS ASS REB FGM FGA FG% 3PM 3PA 3P% FTM FTA FT% STL BLK TO " << endl
<< endl;
}
else
{
cout << "This player does not exist" << endl
<< endl;
}
for (int i = 0; i < 300; i++)
{
if (name == B[i].First_name || name == B[i].Last_name) // checks both first and last name of the player from the file list
{
cout << left << setw(9) << B[i].First_name << setw(17) << B[i].Last_name << setw(5) << B[i].Age << setw(13) << B[i].Team << setw(15) << B[i].Country << setw(15) << B[i].Position << setw(3) << B[i].No_of_matches << setw(5) << B[i].Minutes_played << setw(5) << B[i].Points << setw(4) << B[i].Assists << setw(4) << B[i].Rebounds << setw(4) << B[i].Field_goal_made << setw(5) << B[i].Field_goal_attempt << setw(5) << B[i].Field_goal_percentage << setw(4) << B[i].Three_ptr_made << setw(4) << B[i].Three_ptr_attempt << setw(5) << B[i].Three_ptr_percentage << setw(4) << B[i].Free_throw_made << setw(4) << B[i].Free_throw_attempt << setw(5) << B[i].Free_throw_percentage << setw(4) << B[i].Steals << setw(4) << B[i].Blocks << setw(4) << B[i].Turnover << endl;
cout << "--------------------------------------------------------------------------------------------------------------------------------------------------" << endl;
}
}
}
void Player_display_b(Basketball *B)
{
fstream player_b("basketball_demo.txt");
if (!player_b)
cout << "Error opening the file!!" << endl;
int id[400]; // ID allotted to every player
player_b.seekg(0); //makes the pointer start reading from the beginning
for (int i = 0; i < 300; i++) //inputs all the data into class's objects
{
player_b >> id[i] >> B[i].First_name >> B[i].Last_name >> B[i].Age >> B[i].Team >> B[i].Country >> B[i].Position >> B[i].No_of_matches >> B[i].Win >> B[i].Lost >> B[i].Minutes_played >> B[i].Points >> B[i].Assists >> B[i].Rebounds >> B[i].Field_goal_made >> B[i].Field_goal_attempt >> B[i].Field_goal_percentage >> B[i].Three_ptr_made >> B[i].Three_ptr_attempt >> B[i].Three_ptr_percentage >> B[i].Free_throw_made >> B[i].Free_throw_attempt >> B[i].Free_throw_percentage >> B[i].Steals >> B[i].Blocks >> B[i].Turnover;
}
cout << "SNO F.NAME L.NAME AGE TEAM COUNTRY " << endl
<< endl
<< endl;
for (int i = 0; i < 300; i++) //displays all the players in the league after reading from the file
{
cout << left << setw(4) << id[i] << left << setw(9) << B[i].First_name << left << setw(17) << B[i].Last_name << left << setw(6) << B[i].Age << left << setw(13) << B[i].Team << left << setw(15) << B[i].Country << endl;
cout << "---------------------------------------------------------------" << endl;
}
}
void Display_top10_b_p(Basketball *B)
{
fstream top10_b("basketball_demo.txt");
if (!top10_b)
cout << "Error opening the file!!" << endl;
int id[400]; // ID allotted to every player
top10_b.seekg(0); //makes the pointer start reading from the beginning
for (int i = 0; i < 300; i++) //inputs all the data into class's objects
{
top10_b >> id[i] >> B[i].First_name >> B[i].Last_name >> B[i].Age >> B[i].Team >> B[i].Country >> B[i].Position >> B[i].No_of_matches >> B[i].Win >> B[i].Lost >> B[i].Minutes_played >> B[i].Points >> B[i].Assists >> B[i].Rebounds >> B[i].Field_goal_made >> B[i].Field_goal_attempt >> B[i].Field_goal_percentage >> B[i].Three_ptr_made >> B[i].Three_ptr_attempt >> B[i].Three_ptr_percentage >> B[i].Free_throw_made >> B[i].Free_throw_attempt >> B[i].Free_throw_percentage >> B[i].Steals >> B[i].Blocks >> B[i].Turnover;
}
int points[300];
for (int i = 0; i < 300; i++)
{
points[i] = B[i].Points; //stores all Points from the file in a array
}
int n = sizeof(points) / sizeof(points[0]);
sort(points, points + n, greater<int>()); // sort function to arrange them into descending order
int n1 = 300;
for (int i = 0; i < n1; ++i)
{
for (int j = i + 1; j < n1;)
{
if (points[i] == points[j]) //checks for multiple instances of same points
{
for (int k = j; k < n1 - 1; ++k)
points[k] = points[k + 1];
--n1;
}
else
++j;
}
}
cout << "Rank F.Name L.Name Team MP Points" << endl
<< endl;
for (int i = 0; i < 10; i++)
{
for (int j = 0; j < 300; j++)
{
if (points[i] == B[j].Points) // checks where the given (point) occurs in the stat file
{
cout << left << setw(5) << id[i] << setw(9) << B[j].First_name << setw(17) << B[j].Last_name << setw(13) << B[j].Team << setw(5) << B[j].No_of_matches << setw(5) << B[j].Points << endl;
cout << "--------------------------------------------------------" << endl;
}
}
}
}
void Display_top10_b_a(Basketball *B)
{
fstream top10_b("basketball_demo.txt");
int id[400];
top10_b.seekg(0);
for (int i = 0; i < 300; i++)
{
top10_b >> id[i] >> B[i].First_name >> B[i].Last_name >> B[i].Age >> B[i].Team >> B[i].Country >> B[i].Position >> B[i].No_of_matches >> B[i].Win >> B[i].Lost >> B[i].Minutes_played >> B[i].Points >> B[i].Assists >> B[i].Rebounds >> B[i].Field_goal_made >> B[i].Field_goal_attempt >> B[i].Field_goal_percentage >> B[i].Three_ptr_made >> B[i].Three_ptr_attempt >> B[i].Three_ptr_percentage >> B[i].Free_throw_made >> B[i].Free_throw_attempt >> B[i].Free_throw_percentage >> B[i].Steals >> B[i].Blocks >> B[i].Turnover;
}
int assist[300];
for (int i = 0; i < 300; i++)
{
assist[i] = B[i].Assists;
}
int n = sizeof(assist) / sizeof(assist[0]);
sort(assist, assist + n, greater<int>());
int n1 = 300;
for (int i = 0; i < n1; ++i)
{
for (int j = i + 1; j < n1;)
{
if (assist[i] == assist[j])
{
for (int k = j; k < n1 - 1; ++k)
assist[k] = assist[k + 1];
--n1;
}
else
++j;
}
}
cout << "Rank F.Name L.Name Team MP Assists" << endl
<< endl;
for (int i = 0; i < 10; i++)
{
for (int j = 0; j < 300; j++)
{
if (assist[i] == B[j].Assists)
{
cout << left << setw(5) << id[i] << setw(9) << B[j].First_name << setw(17) << B[j].Last_name << setw(13) << B[j].Team << setw(5) << B[j].No_of_matches << setw(5) << B[j].Assists << endl;
cout << "--------------------------------------------------------" << endl;
}
}
}
}
void Display_top10_b_r(Basketball *B)
{
fstream top10_b("basketball_demo.txt");
int id[400];
top10_b.seekg(0);
for (int i = 0; i < 300; i++)
{
top10_b >> id[i] >> B[i].First_name >> B[i].Last_name >> B[i].Age >> B[i].Team >> B[i].Country >> B[i].Position >> B[i].No_of_matches >> B[i].Win >> B[i].Lost >> B[i].Minutes_played >> B[i].Points >> B[i].Assists >> B[i].Rebounds >> B[i].Field_goal_made >> B[i].Field_goal_attempt >> B[i].Field_goal_percentage >> B[i].Three_ptr_made >> B[i].Three_ptr_attempt >> B[i].Three_ptr_percentage >> B[i].Free_throw_made >> B[i].Free_throw_attempt >> B[i].Free_throw_percentage >> B[i].Steals >> B[i].Blocks >> B[i].Turnover;
}
int rebound[300];
for (int i = 0; i < 300; i++)
{
rebound[i] = B[i].Rebounds;
}
int n = sizeof(rebound) / sizeof(rebound[0]);
sort(rebound, rebound + n, greater<int>());
int n1 = 300;
for (int i = 0; i < n1; ++i)
{
for (int j = i + 1; j < n1;)
{
if (rebound[i] == rebound[j])
{
for (int k = j; k < n1 - 1; ++k)
rebound[k] = rebound[k + 1];
--n1;
}
else
++j;
}
}
cout << "Rank F.Name L.Name Team MP Rebounds" << endl
<< endl;
for (int i = 0; i < 10; i++)
{
for (int j = 0; j < 300; j++)
{
if (rebound[i] == B[j].Rebounds)
{
cout << left << setw(5) << id[i] << setw(9) << B[j].First_name << setw(17) << B[j].Last_name << setw(13) << B[j].Team << setw(5) << B[j].No_of_matches << setw(5) << B[j].Rebounds << endl;
cout << "---------------------------------------------------------" << endl;