-
Notifications
You must be signed in to change notification settings - Fork 0
/
MAP.CPP
136 lines (126 loc) · 2.51 KB
/
MAP.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
/*ASSIGNMENT NO.: 1
TOPIC : CLASSES AND OBJECTS
DESCRIPTION : SIMULATING A CRICKET CUP
D.O.S. : 20-06-19
*/
#include<string.h>
#include<stdio.h>
#include<iostream.h>
#include<stdlib.h>
#include<conio.h>
class cricketcup
{
int c_no;
char c_name[20];
char c_cap[30];
int win;
int loss;
int draw;
int points; /*5 points for win, 2 for draw, 0 for loss */
int total_runs;
public:
void input();
char* get_cname(){return c_name;}
void output_country_info();
int get_c_no(){return c_no;}
char* get_captain(){return c_cap;}
void update(int status);
void calculate_points(){points=5*win+2*draw;}
void output();
int get_points(){return points;}
cricketcup(){
c_no=0;
strcpy(c_cap,"\0");
strcpy(c_name,"\0");
points=0;
total_runs=0;
loss=0;
win=0;
draw=0;
}
};
void cricketcup::output()
{
cout<<c_no<<"\t"<<c_name<<"\t\t"<<c_cap<<"\t"
<<win<<"/"<<loss<<"/"<<draw<<"\t\t"
<<total_runs<<"\t"<<points<<endl;
}
void cricketcup::output_country_info()
{
cout<<"\n\nCountry no.: "<<c_no
<<"\nCountry name: "<<c_name
<<"\nCaptain: "<<c_cap
<<"\nWins: "<<win
<<"\nDraws: "<<draw
<<"\nLosses: "<<loss
<<"\nPoints: "<<points
<<"\nRuns: "<<total_runs;
}
void cricketcup::update(int status)
{
if(status==1)
{
win++;
points+=5;
}
else if(status==0)
{
draw++;
points+=2;
}
else
{
loss++;
}
int runs;
cout<<"\nHow many runs did the team score\n";
cin>>runs;
total_runs+=runs;
}
int count=1;
void cricketcup::input()
{
clrscr();
c_no=count++;
cout<<"For country "<<c_no<<endl<<endl;
cout<<"Enter country name\n";
gets(c_name);
cout<<"Enter captain name\n";
gets(c_cap);
cout<<"Enter no. of wins\n";
cin>>win;
cout<<"Enter no. of loss\n";
cin>>loss;
cout<<"Enter no. of draws\n";
cin>>draw;
cout<<"Enter no. of runs scored\n";
cin>>total_runs;
}
void bubblesort_points(cricketcup teams[],int n)
{
for(int i=0; i<n; i++)
{
for(int j=0; j<n-1-i; j++)
{
if(teams[i].get_points()<teams[i+1].get_points())
{
cricketcup temp=teams[i];
teams[i]=teams[i+1];
teams[i+1]=temp;
}
}
}
}
void main()
{
int op;
int n;
cricketcup teams[20];
cout<<"\t\t\t\tWORLD CRICKET CUP\n\n\n\n";
cout<<"How many teams are playing in this cup?\n";
cin>>n;
clrscr();
for(int i=0; i<n; i++){ teams[i].input(); teams[i].calculate_points(); }
do{
clrscr();
cout<<"\n\n\n\t\t\tWORLD CRICKET