You are on page 1of 33

G.K.

SHETTY VIVEKANANDAVIDYALAYA
JUNIOR COLLEGE

COMPUTER SCIENCE
PROJECT
2018-2019
TITLE:CRICKET SCORE BOARD
BY:
CLASS & SECTION:
ROLL NUMBER:
CONTENT

 Introduction
 Objective of the program
 Program specification
 Header file used
 Sample input & output
 Conclusion
 Bibliography
INTRODUCTION

CRICKET:
Cricket is a bat and ball game
played between two teams of 11 players each in a
cricket field, at the centre of which is a rectangular
22-yards-long(20metres)pitch with a target at each
end called the wickets (a set of three wooden
stumps upon which two bails placed). Each phase of
play is called innings , during which one team bats ,
attempting to score as many runs as possible ,
whilst their opponents bowl and field , attempting
to minimise the number of runs scored. When each
innings ends, the usually swap roles for the next
innings (i.e. the team that previously batted will
bowl/field , and vice versa). The teams each bat for
one or two innings, depending on the type of
match. The winning team is the one that scores the
most runs , including any extras gained (except
when the result is not a win/loss result).

RECORDS OF SCORES:

This is a written or computerised


form of records of scores, averages, highest runs
scored and similar records. This helps the
management board in keeping track the efficiency
of the player. This ensures easy way of inserting,
managing, deleting, displaying records of a players.

OBJECTIVES OF THE PROGRAM


 To obtain the choice of user for the task to
be performed (like insertion or deletion).
 If the choose insertion , get to how many
records they want to insert.
 If they choose to display records , display
them.
 If they choose to search a record, let them
search with players code.
 If they choose to see the highest scores just
display them.
 If they choose to delete a record , let them
delete with player code being given.
 Let them quit the program if they choose
to quit.
PROGRAM SPECIFICATION

This program is designed to keep


records of the batsmen of INDIAN
TEAM.
 Fstream.h header file is
included for the purpose of
using the data file/text files.

 Conio.h header file is used to


make vital use of text
background and text colour.

 Header file graphic.h is also


used enough.
HEADER FILES USED

 fstream.h
 graphic.h
 conio.h
 ctype.h
 stdio.h
 string.h
 process.h
 iostream.h

THE PROGRAM CODE

//CRICKET SCORE RECORDS

#include<fstream.h>
#include<graphics.h>
#include<conio.h>
#include<ctype.h>
#include<stdio.h>
#include<string.h>
#include<process.h>
#include<iostream.h>
class data
{
char name[30];
intplayercode;
int T20;
int Test;
int ODI;
int IPL;
inttotal_run;

public:
data()
{
playercode=0;
strcpy(name," ");
T20=0;
Test=0;
ODI=0;
IPL=0;
total_run=0;
}
voidenter_name_runs()// TO TAKE ENTRY OF NEW RECORDS
{
cout<<"\n Enter player code(Integral) : ";
cin>>playercode;
cout<<"\n Enter player name : ";
gets(name);
cout<<"\n Total runs scored in T20 : ";
cin>>T20;
cout<<"\n Total runs scored in Test matches : ";
cin>>Test;
cout<<"\n Total runs scores in ODI : ";
cin>>ODI;
cout<<"\n Total runs scored in IPL : ";
cin>>IPL;
total_runs();
}
voidshow_record()//TO DISPLAY THE RECORDS EXISTING IN THE
FILE
{
cout<<"\nPlayer code :"<<playercode;
cout<<"\nPlayer name :"<<name;
cout<<"\nRuns scored in T20 :"<<T20;
cout<<"\nRuns scored in TEST :"<<Test;
cout<<"\nRuns scored in ODI :"<<ODI;
cout<<"\nRuns scored in IPL :"<<IPL;
cout<<"\nTotal run(s) :"<<total_run;
}
voidtotal_runs()// CALCULATE TOTAL RUNS
{
total_run=T20+Test+ODI+IPL;
}
intgetplayercode()
{
returnplayercode;
}
intgettotalruns()
{
returntotal_run;
}
char*get_name()
{
return name;
}
voidmodify_data()//TAKE DATA TO MODIFIFY EXISTING RECORD
{
cout<<"\nData to be modified(player's code): ";
cin>>playercode;
cout<<"\nEnter player name: ";
gets(name);
cout<<"\nTotal runs scored in T20: ";
cin>>T20;
cout<<"\nTotalrunsscored in Test matches: ";
cin>>Test;
cout<<"\nTotal runs scored in ODI: ";
cin>>ODI;
cout<<"\nTotal runs scored in IPL: ";
cin>>IPL;
total_runs();
}
};
datad;fstreamfile;fstream file1;
void highest()// CALCULATE HIGHEST RUN
{
file.open("cricket.dat",ios::in|ios::binary);
int post=0,tr=0,run=0;
file.read((char*)&d,sizeof(d));
while(file)
{
run=d.gettotalruns();
if(run>tr)
{
post=file.tellg();
tr=run;
}
file.read((char*)&d,sizeof(d));
}
file.close();
file.open("cricket.dat",ios::in|ios::binary);
file.seekg(post-sizeof(d));
file.read((char*)&d,sizeof(d));
cout<<"\n Highest run scorer";
cout<<"\nCandidate Code :"<<d.getplayercode();
cout<<"\nHighest run scorer :"<<d.get_name();
cout<<"\nHighest runs :"<<tr;
floatavg;
avg=(tr)/4;
cout<<"\nAverage of the batsman :"<<avg;
file.close();
}
void insert()
{
inti,no; file.open("cricket.dat",ios::in|ios::app|ios::binary);
cout<<"\n\t\t\*^*^*^*^*^*^*^*^*^*^*^*^*^*^*";
cout<<"\n\t\t\SELECTION OF DATA INSERTITION";
cout<<"\n\t\t\*^*^*^*^*^*^*^*^*^*^*^*^*^*^*";
cout<<"\nHow many record(s)you want to enter : ";
cin>>no;
for(i=1;i<=no;i++)
{
d.enter_name_runs();//insert records
file.write((char*)&d,sizeof(d));
}

file.close();
}

void display() // DISPLAY THE DETAILS


{
file.open("cricket.dat",ios::in||ios::binary);
cout<<"\n&^&^&^&^&^&^&^#COMPLETE INFORMATION ABOUT
THE CANDIDATE#^&^&^&^&^&^&^";
file.read((char*)&d,sizeof(d));
while(file)
{
d.show_record();
file.read((char*)&d,sizeof(d));
}
file.close();
}
void search()//SEARCH RECORD
{
intp,r,srch=0;
file.open("cricket.dat",ios::in||ios::binary);
cout<<"\nEnter the player code to view his details:";
cin>>r;
file.seekg(0);
file.read((char*)&d,sizeof(d));
while(file)
{
p=d.getplayercode();
if(r==p)
{
d.show_record();
srch=1;
break;
}
else
{
file.read((char*)&d,sizeof(d));}
}
file.close();
if(srch==0)
{
cout<<"\nNo details are avaliable under the player code"<<r<<"!";
}
}

void modify()//MODIFY DATA

{
intposi=0,got=0,dmd=0;
cout<<"\nEnter the playercode whose record to be modified:";
cin>>dmd;
intifdata=1;
file.open("cricket.dat",ios::in||ios::out||ios::binary);
posi=file.tellg();
while(file)
{
file.read((char*)&d,sizeof(d));
got=d.getplayercode();
if(dmd==got)
{
file.seekg(posi);
d.modify_data();
ifdata=2;
file.write((char*)&d,sizeof(d));
break;
}
posi=file.tellg();
}
file.close();
if(ifdata==1)
{
cout<<"\nNo such record exits for modification!";
}
}
voiddelete_record()//DELETE RECORD
{
intremove_record=0,code_get=0,m=0;
cout<<"\n Enter the player code whose record to be deleted:";
cin>>remove_record;
file.open("cricket.dat",ios::in|ios::out|ios::binary);
file1.open("temp.dat",ios::in|ios::out|ios::binary);
file.seekg(0);
while(file)
{
file.read((char*)&d,sizeof(d));
code_get=d.getplayercode();
if(remove_record==code_get)
{
cout<<" ";m=1;
}
else
{
file1.write((char*)&d,sizeof(d));
}
}file.close();
file.close();
if(m==0)
{
cout<<"sorry!No such data is avaliable for deletion";
}
remove("cricket.dat");
rename("temp.dat","cricket.dat");
}
void main()
{
clrscr();
int choice;
charans='n';

textcolor(15);
textbackground(1);
cprintf("||||||||||||||||BATSMEN RECORD||||||||||||||||");
cout<<"\n\nThe source code is easy to understand and it ensures
ergonomic(effective human and machinery interaction)design.";
cout<<"\nThis program contains 7 options for the user regarding
match details,player details and their achivements.";
printf("\n");
cout<<" ";
getch();
textcolor(6);
textbackground(6);
cprintf("|TEAM*INDIA|");
printf("\n");
cout<<" ";
textcolor(0);
textbackground(7);
cprintf(" ");
textcolor(0);
cprintf(" INDIA ");
printf("\n");
cout<<" ";
textbackground(2);
textcolor(2);
cprintf("|TEAM*INDIA|");
printf("\n");
start:
cout<<"\n=*=*=*=*=*=*=*=*=*=*=*=*CRICKET CANDIDATE
MENU*=*=*=*=*=*=*=*";
cout<<"\n1.INSERT DETAILS /~/";
cout<<"\n2.DISPLAY DETAILS /M/";
cout<<"\n3.SEARCH RECORD /S/";
cout<<"\n4.MODIFY DATA /D/";
cout<<"\n5.HIGHEST RUNS ~//~ ";
cout<<"\n6.DELETE RECORD // ";
cout<<"\n7.EXIT ~ ";
cout<<"\nEnter any one of the options:";
cin>>choice;
switch(choice)
{case 1:insert();
break;
case 2:display();
break;
case 3:search();
break;
case 4:modify();
break;
case 5:highest();
break;
case 6:delete_record();
break;
case 7:exit(0);
break;
default:cout<<"\n Enter choice between 1 to 6";
}
cout<<"\nDo you want to choose any other option?";
cin>>ans;
if((ans=='Y')||(ans=='y'))
{goto start;}
getch();
}
SAMPLE INPUT &
OUTPUT:

INTRODUCTION
INSERTION
DISPLAY

SEARCH
HIGHEST RUN SCORER
DELETION AND VERIFICATION

MODIFICATION
EXIT
BIBLIOGRAPHY
 www.wikipedia.com
 www.google.com
 Computer science with c++
(Sumitha Arora)
**CONCLUSION**
MERITS:
 This program lets you modify, search and insert
records without much complication.
 Only few details are present hence time for
execution will be less.

DEMERITS:

 Details about bowlers are not available.

 Details in particular about every matches is


not present.
THE END

You might also like