Skip to main content

The CricBoard - A C++ Project

//All this is made with the knowledge of C++ till class 11, so it might seem to be a bit lengthy...
#include<iostream>
#include<stdlib.h>
#include<stdio.h>
struct bat{
char name[26];
int run;
int ball;
float strrate;
int flag;
}bats[11];
struct bowl{
char name[26];
int run;
int overs;
float econ;
int wicket;
}bowls[5];
using namespace std;
void title(void)
{
system("cls");
cout<<"\n\t\tThe CricBoard\n";
cout<<"\t\t_____________\n\n";
}
void benter(bat B[]);
void blenter(bowl B[]);
void bdisplay(void);
void bldisplay(void);
void bedit(int);
void bwedit(int);
int main()
{
punarvichaar: int ch,_ch2;
title();
cout<<"Choose from the below two options (Enter 1 or 2):"
<<"\n\n1. Enter the Batting Statistics first"
<<"\n\n2. Enter the Bowling Statistics first\n\n";
cin>>ch;
if(ch==1)
{ benter(bats); blenter(bowls);
} else if(ch==2)
{ blenter(bowls);  benter(bats);
} else goto punarvichaar;
punarvichaar2:
title();
cout<<"What do you want now (select from the below given) : \n"
<<"*You will be returned to this screen after the completion of any of the first two options, select 3 to exit then.\n\n"
  <<"\n1. Edit the statistics entered "
<<"\n2. Show the scoreboards"
<<"\n3. Exit\n\n";
cin>>_ch2;
if(_ch2==1) {
punarvichaar3a:
title();
int e_ch,bno;
cout<<"Which of these do you want to edit ?"
<<"\n\n1. Batting"
<<"\n2. Bowling\n\n";
cin>>e_ch;
if(e_ch==1){
cout<<"\n\nEnter the batsman's number/position :\n";
cin>>bno;
bedit(bno);
}
else if(e_ch==2){
cout<<"\n\nEnter the bowler's number :\n";
cin>>bno;
  bwedit(bno);
}
else goto punarvichaar3a;
}
else if(_ch2==2)
{
punarvichaar3b:
title();
int e_ch;
cout<<"Which of these do you want to see ?"
<<"\n\n1. Batting"
<<"\n2. Bowling\n\n";
cin>>e_ch;
if(e_ch==1){
      bdisplay();
      cout<<"\n\nEnter any number to go back...";
int for_delay;
cin>>for_delay;
}
else if(e_ch==2){
  bldisplay();
cout<<"\n\nEnter any number to go back...";
int for_delay;
cin>>for_delay; }
else goto punarvichaar3b;
}
else if(_ch2==3) exit(0);
goto punarvichaar2;
return 0;
}
void benter(bat B[])
{
int ch;
title();
cout<<"Now, Enter the details of the batsamen performance :";
for(int i=0;i<11;i++)
{
cout<<"\n\nBatsman no. "<<i+1;
cout<<"\n_____________\n"<<"\nEnter his/her name :";
gets(B[i].name);
cout<<"\nEnter runs scored :"; cin>>B[i].run;
cout<<"\nHow many balls did the batsman play ?"; cin>>B[i].ball;
B[i].strrate=B[i].run*100/B[i].ball;
cout<<"Enter 0 if out, 1 if not out, or, any other if not played :";
cin>>ch;
if(!ch)
B[i].flag=0;
else if(ch==1) B[i].flag=1;
else B[i].flag=2;
}
}
void blenter(bowl W[])
{
title();
cout<<"Now, Enter the details of the bowlers performance :";
for(int i=0;i<5;i++)
{
cout<<"\n\nBowler no. "<<i+1;
cout<<"\n_____________\n"<<"\nEnter his/her name :";
gets(W[i].name);
cout<<"\nEnter runs given :"; cin>>W[i].run;
cout<<"\nHow many overs did the bowler bowl ?"; cin>>W[i].overs;
W[i].econ=W[i].run/W[i].overs;
wrong:
cout<<"\nNumber of wickets taken by the bowler :";
cin>>W[i].wicket;
if(W[i].wicket>10) {
cout<<"Wrong detail entered, try again...\n\n"; goto wrong; }
}
}
void bedit(int m)
{ int n=m-1,ch;
cout<<"\n__________________________________________________"
<<"\n\nBatsman no. "<<m;
cout<<"\n_____________\n"<<"\nEnter his/her name :";
cin.getline(bats[n].name,26);
cout<<"\nEnter runs scored :"; cin>>bats[n].run;
cout<<"\nHow many balls did the batsman play ?"; cin>>bats[n].ball;
bats[n].strrate=(float)(bats[n].run*100/bats[n].ball);
cout<<"Enter 0 if out, 1 if not out, or, any other if not played :";
cin>>ch;
if(!ch)
bats[n].flag=0;
else if(ch==1) bats[n].flag=1;
else bats[n].flag=2;
}
void bwedit(int m)
{ int n=m-1,ch;
cout<<"\n__________________________________________________"
<<"\n\nBowler no. "<<m;
cout<<"\n_____________\n"<<"\nEnter his/her name :";
cin.getline(bowls[n].name,26);
cout<<"\nEnter runs given :"; cin>>bowls[n].run;
cout<<"\nHow many overs did the bowler bowl ?"; cin>>bowls[n].overs;
bowls[n].econ=(float)(bowls[n].run/bowls[n].overs);
wrong:
cout<<"\nNumber of wickets taken by the bowler :";
cin>>bowls[n].wicket;
if(bowls[n].wicket>10) {
cout<<"Wrong detail entered, try again...\n\n"; goto wrong; }
}
void bdisplay(void)
{
title();
for(int i=0;i<11;i++)
{
cout<<"\n\nBatsman no. "<<i+1;
cout<<"\n_____________\n"<<"\nName : "<<bats[i].name;
cout<<"\nRuns scored :"<<bats[i].run;
cout<<"\nBalls Played : "<<bats[i].ball;
bats[i].strrate=(float)(bats[i].run*100/bats[i].ball);
cout<<"\nStrike Rate : "<<bats[i].strrate;
cout<<"\nPresent State : ";
if(!bats[i].flag) cout<<"Out";
else if(bats[i].flag==1) cout<<"Not Out";
else cout<<"Didn't Play";
}
}
void bldisplay(void){
title();
for(int i=0;i<5;i++)
{
cout<<"\n\nBowler no. "<<i+1;
cout<<"\n_____________\n"<<"\nName : "<<bowls[i].name;
cout<<"\nRuns given : "<<bowls[i].run;
cout<<"\nOvers Bowled : "<<bowls[i].overs;
bowls[i].econ=(float)(bowls[i].run/bowls[i].overs);
cout<<"\nEconomy of bowler : "<<bowls[i].econ;
cout<<"\nNumber of wickets taken by the bowler : "<<bowls[i].wicket;
}
}

//You may want to share this if its good @_@

Comments

Popular posts from this blog

Using 'ls' command as a replacement of 'find'

Advantage over find - Actually not probably in terms of speed, but... only point of this is that it's an observation, but... you can do like 'search only in' */*/*Programs* , /*/*Programs*/* , this may compensate the extra time took by using two commands 1. To search in current folder only (1 level... only this folder, no subfolder)     Type... ls | grep Search_Term 2. To search in current folder only (till level 2... this folder + subfolder)     Type... ls * | grep Search_Term #ls and ls * are NOT same! 3. To search in current folder only (till level 3... this folder + subfolder + subfolder)     Type... ls */* | grep Search_Term 4. To search in current folder only (till level 4... this folder + subfolder + subfolder + subfolder)     Type... ls */*/* | grep Search_Term ... and so on... FORMULA - To search till 'n' level (considering current folder as 1)... go till (n-1) stars If wanting to search whole disk... better type star...

Most Code will now be at my GitHub - github.com/adi-g15

Friends... i didn't update this blog for a month. But actually it was the period of time, i LEARNED and DID the most. The sole purpose of this blog for me, was just to put 'Interesting Observations' i used to get during finding or solving the errors, and some just clicked to try. Now, that i have actually been trying many languages and design, so most of the new code part will be on GitHub from now on... Thanks for reading... and I WILL keep posting more inferences here (I got dozens in this month due to the projects ;D ). And special thanks to DevHack1.0 team! GitHub link -> https://github.com/AdityaGupta150

LudO - The Game

/* Programmer - Aditya Gupta (Techy15) Language - C++ Program - LudO - The Game */ /* PLANS- Add functionality for name of player */ //IMP NOTE - See all notes, written in this form "//NOTE..." //NOTE- Mark 'R','G','B','Y' for gotis, ignore doubling for now //NOTE- Settings will have options: change default game play order(ie RBYG), change/give names to each colour //NOTE- Add code in case of attacks //NOTE- Add stops, and ways to show them distinct from others {may require graphics.h} #include<iostream> /* #include<fstream>    To be used in case save & resume to be used*/ #include<cstdio> #include<cstdlib> using namespace std; //Changes on 16th Oct //Show gotis as R1, R2... and ask user to enter string R1 or whatever // // Place within appropriate block ...     short diethrow(){     int fl=1; //holds 0 if decnum is 0     while(fl==0) { char *temp;     ...