#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<ctype.h>
#include<stdlib.h>
int wkt=0,tm,op;
char *batsman;
void play(int);
void batsmann(int);
void bowler(int);
void main()
{
clrscr();
textbackground(WHITE);
textcolor(4);
clrscr();
int tos;
char toss;
cout<<"\n\n\n\n\n\n\n\n\n\n::::::==::==::==::==::==::==::::*****CRICKET*****::::==::==::==::==::==::==:::::\n ";
getch();
cout<<"\n noah @ my own creations";
getch();
cout<<" \n\n\n PLUS ONE - COMPUTER SCIENCE";
getch();
clrscr();
textbackground(YELLOW);
textcolor(4);
clrscr();
cout<<"\n\n\n S=E=L=E=C=T Y=O=U=R T=E=A=M";
cout<<"\n\n\n\n ##:-FOR INDIA 1";
cout<<"\n\n\n\n\n ##:-FOR PAKSITAN 2";
cout<<"\n\n\n\n\n ##:-FOR AUSTRALIA 3";
cout<<"\n\n\n ENTER YOUR CHOICE::- ";
cin>>tm;
clrscr();
cout<<"\n\n\n ::::P=L=A=Y=E=R=S::::";
switch(tm)
{
case 1:
{
india:
cout<<" - Indian Team\n\n\n";
cout<<" ##:- Sachin Tendulkar\n\n";
cout<<" ##:- Yuvaraj Singh\n\n";
cout<<" ##:- Harbhajan Singh\n\n\n";
break;
}
case 2:
{
cout<<" - Pakistan Team\n\n\n";
cout<<" ##:- Taufeeq Umar\n\n";
cout<<" ##:- Shahid Afridi\n\n";
cout<<" ##:- Saeed Ajmal\n\n\n";
break;
}
case 3:
{
cout<<" - Australian Team\n\n\n";
cout<<" ##:- Michael Clarke\n\n";
cout<<" ##:- Mitchell Johnson\n\n";
cout<<" ##:- Nathan Lyon\n\n\n\n";
break;
}
default:
{
tm=1;
cout<<" - AUTO SELECTION(Team India)\n\n\n";
cout<<" YOU MADE AN INVALID CHOICE, SO YOUR TEAM IS AUTOMATICALLY SELECTED\n\n\n\n";
goto india;
}
}
getch();
clrscr();
cout<<"\n\n\n S=E=L=E=C=T Y=O=U=R O=P=P=O=N=E=N=T T=E=A=M ";
cout<<"\n\n\n\n ##:-FOR INDIA 1";
cout<<"\n\n\n\n\n ##:-FOR PAKSITAN 2";
cout<<"\n\n\n\n\n ##:-FOR AUSTRALIA 3";
cout<<"\n\n\n ENTER YOUR CHOICE::- ";
cin>>op;
clrscr();
cout<<"\n\n\n ::::P=L=A=Y=E=R=S::::";
switch(op)
{
case 1:
{
if(op!=tm)
{
cout<<" - Indian Team\n\n\n";
cout<<" ##:- Sachin Tendulkar\n\n";
cout<<" ##:- Yuvaraj Singh\n\n";
cout<<" ##:- Harbhajan Singh\n\n\n";
break;
}
else
{
goto bottom;
}
}
case 2:
{
if(op!=tm)
{
cout<<" - Pakistan Team\n\n\n";
cout<<" ##:- Taufeeq Umar\n\n";
cout<<" ##:- Shahid Afridi\n\n";
cout<<" ##:- Saeed Ajmal\n\n\n";
break;
}
else
{
goto bottom;
}
}
case 3:
{
if(op!=tm)
{
cout<<" - Australian Team\n\n\n";
cout<<" ##:- Michael Clarke\n\n";
cout<<" ##:- Mitchell Johnson\n\n";
cout<<" ##:- Nathan Lyon\n\n\n\n";
break;
}
else
{
goto bottom;
}
}
case 4:
{
english:
{
cout<<" - English Team\n\n\n";
cout<<" ##:- Alastair Cook\n\n";
cout<<" ##:- Ian Bell\n\n";
cout<<" ##:- James Anderson\n\n\n\n";
break;
}
}
default:
{
bottom:
{
op=4;
cout<<" -AUTO SELECTION\n\n\n";
cout<<" YOU MADE AN INVALID CHOICE, SO YOUR TEAM IS AUTOMATICALLY SELECTED\n\n\n\n";
goto english;
}
}
}
getch();
clrscr();
textbackground(WHITE);
clrscr();
cout<<" .............................YOUR GAME IS LOADING.............................";
cout<<"\n\n G::A::M::E D::E::T::A::I::L::S";
cout<<"\n\n @ 12 Ball Game";
cout<<"\n\n @ Each Team Have THREE Wickets";
cout<<"\n\n @ Only Use Keys From 1 ,upto 6";
cout<<"\n\n @ Using Of Any Other Key Is Considered As: \n";
cout<<" While Batting: Loss Of 1 WICKET ";
cout<<"\n\n While Bowling: Wide Ball";
cout<<"\n\n\n\n\n TOSS(b= Batting,t= Bowling): ";
cin>>toss;
toss=tolower(toss);
if(toss=='b')
{
cout<<"\n\n You Choose To Bat First";
tos=1;
}
if(toss=='t')
{
cout<<"\n\n You Choose To Bowl First";
tos=2;
}
if(toss!='b' && toss!='t')
{
cout<<"\n\n YOU MADE AN INVALID CHOICE, SO YOUR TOSS IS AUTOMATICALLY SELECTED";
cout<<"\n\n Auto Selected- Bat First";
tos=1;
}
play(tos);
getch();
}
void play(int tes)
{
clrscr();
textbackground(YELLOW);
textcolor(4);
clrscr();
int ovrbat,ovrbt,wkt=0,runs=0,i,b,runsop=0;
if(tes==1)
{
for(ovrbt=0;ovrbt<12 && wkt<3;ovrbt++)
{
cout<<"\n\n\n\n BALLS:: "<<ovrbt;
cout<<"WICKET::-"<<wkt;
cout<<" BATSMAN: ";
batsmann(wkt);
cout<<"Enter Runs::- ";
cin>>i;
ovrbat=rand() % 6 + 1;
cout<<"Bowler Shows::- "<<ovrbat;
if(i!=ovrbat && i<7)
{runs=runs+i;
cout<<"Your Current Score::- "<<runs;}
else
{
cout<<batsman;
cout<<" Is Out";
wkt++;}
}
cout<<"Total Score::- "<<runs;
cout<<"::INNINGS OVER:: ";
cout<<"\n\n\n\n\nYOUR OPPONENT IS WAITING AHEAD FOR THE WAR";
getch();
clrscr();
for(ovrbt=0,wkt=0;ovrbt<12 && wkt<3 && runs>=runsop;ovrbt++)
{
cout<<"\n\n\n\n BALLS:: "<<ovrbt;
cout<<"WICKET::-"<<wkt;
cout<<" BATSMAN: ";
bowler(wkt);
cout<<"You Need To Ball::- ";
cin>>i;
ovrbat = rand() % 6 + 1;
cout<<"Batter Shows::- "<<ovrbat;
if(i!=ovrbat && i<7)
{runsop=runsop+ovrbat;
cout<<"Opponents Current Score::- "<<runsop;}
else
{
if(i==ovrbat)
{cout<<batsman;
cout<<"Is Out";wkt++;}
else
{runsop=runsop+1;
cout<<"Opponents Current Score::- "<<runsop;ovrbt=ovrbt-1;}
}
}
cout<<"::INNINGS OVER:: ";
}
else
{
for(ovrbt=0;ovrbt<12 && wkt<3;ovrbt++)
{
cout<<"\n\n\n\n BALLS:: "<<ovrbt;
cout<<"WICKET::-"<<wkt;
cout<<" BATSMAN: ";
bowler(wkt);
cout<<"You Need To Ball::- ";
cin>>i;
ovrbat = rand() % 6 + 1;
cout<<"Batter Shows::- "<<ovrbat;
if(i!=ovrbat && i<7)
{runsop=runsop+ovrbat;
cout<<"Opponents Current Score::- "<<runsop;}
else
{
if(i==ovrbat)
{cout<<batsman;
cout<<"Is Out";wkt++;}
else
{runsop=runsop+1;
cout<<"Opponents Current Score::- "<<runsop;ovrbt=ovrbt-1;}
}
}
cout<<"Opponent Scored::- "<<runsop;
cout<<"::INNINGS OVER:: ";
cout<<"\n\n\n\n\nGO AHEAD FOR THE WAR";
getch();
clrscr();
for(ovrbt=0,wkt=0;ovrbt<12 && wkt<3 && runsop>=runs;ovrbt++)
{
cout<<"\n\n\n\n BALLS:: "<<ovrbt;
cout<<"WICKET::-"<<wkt;
cout<<" BATSMAN: ";
batsmann(wkt);
cout<<"Enter Runs::- ";
cin>>i;
ovrbat=rand() % 6 + 1;
cout<<"Bowler Shows::- "<<ovrbat;
if(i!=ovrbat && i<7)
{runs=runs+i;
cout<<"Your Current Score::- "<<runs;}
else
{
cout<<batsman;
cout<<" Is Out";
wkt++;}
}
}
if(runs>runsop)
{
cout<<"You Won";
getch();
clrscr();
exit(0);
}
else
{
if(runsop>runs)
{
cout<<"You Lose";
getch();
clrscr();
exit(0);
}
else
{
cout<<"DRAW game";
getch();
clrscr();
exit(0);
}
}
return;
}
void batsmann(int wkt)
{
if(tm==1)
{
if(wkt==0){
cout<<"S.Tendulkar";
batsman= "Tendulkar";
}
if(wkt==1){
cout<<"Yuvaraj Singh";
batsman= "Yuvaraj";
}
if(wkt==2){
cout<<"Harbhajan Singh";
batsman= "Bhaaji";
}
}
if(tm==2)
{
if(wkt==0){
cout<<"Taufeeq Umar";
batsman= "TUmar";
}
if(wkt==1){
cout<<"Shahid Afridi";
batsman= "Afridi";
}
if(wkt==2){
cout<<"Saeed Ajmal";
batsman= "Ajmal";
}
}
if(tm==3)
{
if(wkt==0){
cout<<"Michael Clarke";
batsman= "Clarke";
}
if(wkt==1){
cout<<"Mitchell Johnson";
batsman= "Johnson";
}
if(wkt==2){
cout<<"Nathan Lyon";
batsman= "Lyon";
}
}
return;
}
void bowler(int wkt)
{
if(op==1)
{
if(wkt==0){
cout<<"S.Tendulkar";
batsman= "Tendulkar";
}
if(wkt==1){
cout<<"Yuvaraj Singh";
batsman= "Yuvaraj";
}
if(wkt==2){
cout<<"Harbhajan Singh";
batsman= "Bhaaji";
}
}
if(op==2)
{
if(wkt==0){
cout<<"Taufeeq Umar";
batsman= "TUmar";
}
if(wkt==1){
cout<<"Shahid Afridi";
batsman= "Afridi";
}
if(wkt==2){
cout<<"Saeed Ajmal";
batsman= "Ajmal";
}
}
if(op==3)
{
if(wkt==0){
cout<<"Michael Clarke";
batsman= "Clarke";
}
if(wkt==1){
cout<<"Mitchell Johnson";
batsman= "Johnson";
}
if(wkt==2){
cout<<"Nathan Lyon";
batsman= "Lyon";
}
}
if(op==4)
{
if(wkt==0){
cout<<"Alastair Cook";
batsman= "Cook";
}
if(wkt==1){
cout<<"Ian Bell";
batsman= "Bell";
}
if(wkt==2){
cout<<"James Anderson";
batsman= "Anderson";
}
}
return;
}
compiled and tested with:
thank you - noah paul