Professional Documents
Culture Documents
Cricket Mini Game
Cricket Mini Game
ncl
ude<i
ost
ream>
#i
ncl
ude<cst
dli
b>
#i
ncl
ude<uni
std.
h>
#i
ncl
ude<ct
ime>
usi
ngnamespacest
d;
cl
assTeam {
publ
i
c:
st
ri
ngname;
st
ri
ngpl
ayer
s[3]
;
i
ntr
uns;
}
;
v
oidwel
comeUser
s()
;
v
oidst
art
Inni
ng(
int
,st
ri
ng,
str
ing)
;
v
oiddi
spl
ayPl
ayer
s(st
ri
ng[
],
str
ing[
])
;
v
oidsel
ect
Bat
smanAndBowl
er(
Team,
Team)
;
st
ri
ngsel
ect
Play
er(
str
ing[
])
;
i
ntpl
ayI
nni
ng(
);
v
oiddi
spl
ayScor
e(Team)
;
v
oiddeci
deWi
nner
(i
nt,
int
);
st
ri
ngcur
rent
Bat
sman,
cur
rent
Bowl
er;
i
ntmai
n(){
wel
comeUser
s()
;
Team t
eamA;
t
eamA.
play
ers[
0]="
Sat
wik"
;
t
eamA.
play
ers[
1]="
Nimi
sh"
;
t
eamA.
play
ers[
2]="
Soumj
i
t";
t
eamA.
name="
Topper
s";
Team t
eamB;
t
eamB.
play
ers[
0]="
Imr
an"
;
t
eamB.
play
ers[
1]="
Kal
yaan"
;
t
eamB.
play
ers[
2]="
Adar
sh"
;
t
eamB.
name="
Aver
age"
;
di
spl
ayPl
ayer
s(t
eamA.
play
ers,
teamB.
play
ers)
;
st
art
Inni
ng(
1,t
eamA.
name,
teamB.
name)
;
sel
ect
Bat
smanAndBowl
er(
teamA,
teamB)
;
t
eamA.
runs=pl
ayI
nni
ng(
);
di
spl
ayScor
e(t
eamA)
;
cout<<"
\n*
***
***
***
*TeamBneeds"<<t
eamA.
runs+1<<"r
unst
owi
n**
***
***
***
"<<endl
<<endl;
st
art
Inni
ng(
2,t
eamB.
name,
teamA.
name)
;
sel
ect
Bat
smanAndBowl
er(
teamB,
teamA)
;
t
eamB.
runs=pl
ayI
nni
ng(
);
di
spl
ayScor
e(t
eamB)
;
deci
deWi
nner
(teamA.
runs,
teamB.
runs)
;
r
etur
n0;
/
*Gr
eetuser
swi
thawel
comemessage*
/
v
oidwel
comeUser
s(){
cout<<"
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
-"<<endl
;
cout<<"
|===========GULLYCRI
CKET===========|
"<<endl
;
cout<<"
| |
"<<endl
;
cout<<"
| Wel
comet
oGul
l
yCr
icket |
"<<endl
;
cout<<"
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
-"<<endl
;
/
*Di
spl
ayal
lthepl
ayer
sinbot
hteam Aandt
eam B*
/
v
oiddi
spl
ayPl
ayer
s(st
ri
ngpl
ayer
sA[
3],
str
ingpl
ayer
sB[
3]){
cout<<"
\nPr
essEnt
ert
odi
spl
aypl
ayer
s:"
;
ci
n.get
();
cout<<"
Displ
ayi
ngpl
ayer
s..
.\
n";
usl
eep(
1000*1000)
;
cout<<"
--
--
--
--
--
--
--
--
--
--
--
--
--
\t\
t--
--
--
--
--
--
--
--
--
--
--
--
--
"<<endl
;
cout<<"
|=======Team-
A =======|
\t
\t|
=======Team-
B =======|
"<<endl
;
cout<<"
--
--
--
--
--
--
--
--
--
--
--
--
--
\t\
t--
--
--
--
--
--
--
--
--
--
--
--
--
"<<endl
;
f
or(
inti
=0;
i<3;
i++){
cout<<"
|\
t";
cout<<"
["<<i
<<"
]"<<pl
ayer
sA[
i]<<"
\t|
";
cout<<"
\t\
t|
\t
";
cout<<"
["<<i
<<"
]"<<pl
ayer
sB[
i]<<"
\t|
";
cout<<endl
;
cout<<"
--
--
--
--
--
--
--
--
--
--
--
--
--
\t\
t--
--
--
--
--
--
--
--
--
--
--
--
--
"<<endl
<<endl
;
/
*Sel
ectcur
rentbat
smanandbowl
erf
rom bat
ti
ngt
eam andbowl
ert
eam r
espect
ivel
y*/
v
oidsel
ect
Bat
smanAndBowl
er(
Team bat
Team,
Team bowl
Team){
cout<<"
PressEnt
ert
osel
ectbat
smanandbowl
er:
";
ci
n.get
();
cout<<"
Sel
ect
ingbat
smanandbowl
er.
..
\n"
;
usl
eep(
1000*1000)
;
cur
rent
Bat
sman=sel
ect
Play
er(
bat
Team.
play
ers)
;
cur
rent
Bowl
er=sel
ect
Play
er(
bowl
Team.
play
ers)
;
cout<<"
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
"<<endl
;
cout<<"
\t\
t"<<bat
Team.
name<<"
:Bat
sman-"<<cur
rent
Bat
sman<<endl
;
cout<<"
\t\
t"<<bowl
Team.
name<<"
:Bowl
er-"<<cur
rent
Bowl
er<<endl
;
cout<<"
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
"<<endl
<<endl
;
/
*Sel
ectapl
ayeramongt
hegi
venpl
ayer
srandoml
y*/
st
ri
ngsel
ect
Play
er(
str
ingpl
ayer
s[3]
){
i
ntr
andomVal
ue;
sr
and(
ti
me(
NULL)
);
r
andomVal
ue=r
and(
)%3;
//Gener
atesei
ther0,
1,or2
st
ri
ngsel
ect
edPl
ayer
Name=pl
ayer
s[r
andomVal
ue]
;
r
etur
nsel
ect
edPl
ayer
Name;
/
*St
arti
nni
ngbydi
spl
ayi
ngi
nit
ial
inni
ngdet
ail
s*/
v
oidst
art
Inni
ng(
inti
nni
ng,
str
ingbat
Team,
str
ingbowl
Team){
cout<<"
PressEnt
ert
ost
arti
nni
ng"<<i
nni
ng;
ci
n.get
();
usl
eep(
1000*1000)
;
cout<<"
|-
--
--
--
--
--
-Inni
ng"<<i
nni
ng<<"St
art
s--
--
--
--
--
--
|"<<endl
;
cout<<"
|-
--
--"<<bat
Team <<"i
sbat
ti
ngand"<<bowl
Team <<"i
sbowl
i
ng-
--
--
|"<<endl
<<
endl;
/
*Pl
ayonei
nni
ng(
6bal
l
s)*
/
i
ntpl
ayI
nni
ng(
){
i
ntr
uns=0;
consti
ntMAX_
BALLS=6;
f
or(
inti
=0;
i<MAX_
BALLS;
i++){
cout<<"
PressEnt
ert
obowl
..
."
;
ci
n.get
();
cout<<"
Bowl
i
ng.
..
"<<endl
<<endl
;
usl
eep(
1000*1000)
;
i
ntr
andomVal
ue;
sr
and(
ti
me(
NULL)
);
r
andomVal
ue=r
and(
)%7;/
/0,
1,2,
3,4,
5,or6
r
uns=r
uns+r
andomVal
ue;
cout<<"
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
"<<endl
;
cout<<"
|\
t\t
"<<cur
rent
Bowl
er<<"t
o"<<cur
rent
Bat
sman<<""<<r
andomVal
ue<<"r
uns"
<<endl
;
cout<<"
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
"<<endl
<<endl
;
r
etur
nruns;
/
*Di
spl
ayr
unsscor
edbybat
ti
ngt
eam i
nthei
nni
ng*
/
v
oiddi
spl
ayScor
e(Team t
eam){
cout<<"
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
"<<endl
;
cout<<"
\t\
t"<<t
eam.
name<<"scor
ed"<<t
eam.
runs<<"r
uns.
"<<endl
;
cout<<"
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
"<<endl
<<endl
;
/
*Deci
dewi
nnerbycompar
ingf
inal
scor
esofbot
hthet
eams*
/
v
oiddeci
deWi
nner
(i
ntt
eamAScor
e,i
ntt
eamBScor
e){
cout<<"
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
"<<endl
;
i
f(t
eamAScor
e>t
eamBScor
e){
cout<<"
\t\
tTopper
sist
heWi
nner
"<<endl
;
}el
sei
f(t
eamAScor
e<t
eamBScor
e){
cout
<<"
\t\
tAv
eragei
stheWi
nner
"<<endl
;
}el
se{
cout<<"
\t\
tMat
chDr
aw"<<endl
;
cout<<"
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
"<<endl
<<endl
;
cout
<<"-
--
--
--
--
--
--
--
-MadebyRi
shabhandPur
u--
--
--
--
--
--
--
--
--
-"
<<endl
<<endl
;