Scor Board
Scor Board
Scor Board
#include<graphics.h>
#include<stdio.h>
void ClearConsoleToColors(int ForgC, int BackC)
{
WORD wColor = ((BackC & 0x0F) << 4) + (ForgC & 0x0F);
///Get the handle to the current output buffer...
HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
///This is used to reset the carat/cursor to the top left.
COORD coord = {0, 0};
///A return value... indicating how many chars were written
/// not used but we need to capture this since it will be
/// written anyway (passing NULL causes an access violation).
DWORD count;
///This is a structure containing all of the console info
/// it is used here to find the size of the console.
CONSOLE_SCREEN_BUFFER_INFO csbi;
///Here we will set the current color
SetConsoleTextAttribute(hStdOut, wColor);
if(GetConsoleScreenBufferInfo(hStdOut, &csbi))
{
///This fills the buffer with a given character (in this case 32=space).
FillConsoleOutputCharacter(hStdOut, (TCHAR) 32, csbi.dwSize.X *
csbi.dwSize.Y, coord, &count);
FillConsoleOutputAttribute(hStdOut, csbi.wAttributes, csbi.dwSize.X *
csbi.dwSize.Y, coord, &count );
///This will set our cursor position for the next print statement.
SetConsoleCursorPosition(hStdOut, coord);
}
return;
}
void clearWindow(){
int i,j;
for(i = 37; i < 78; i++){
for(j = 7; j < 25; j++){
gotoxy(i,j);printf(" ");
}
}
return;
}
void window(){
setcolor(35);
printf("\n\t\t\t**");printf("\n\t\t\tCRICKET PREMIERE LEAGUE\n ");printf("\n\t\t\
t*");
printf("\n\t\t\tVASAVI COLLEGE OF ENGINEERING\n");
printf("\n\t\t\t**\n");
setcolor(17);
}
int sum1=0;
int sum2=0;
int w2=0;
int w1=0;
int b2=1;
int b1=1;
int main()
main:
ClearConsoleToColors(17,15);
SetConsoleTitle("\n\tCRICKET SCORE READER");
window();
scanf("%d",&ch);
switch(ch)
case 0:
break;
/* ***Instructions** */
case 1:
system("cls");
printf("\n\t\
t==================================================================================
==============\n\t\t\t\t\tINSTRUCTIONS TO BE FOLLOWED IN THE MATCH\n\t\
t==================================================================================
==============\n\n");
printf("0:Dot Ball\n1:Single Run\n2:Two Runs\n3:Three Runs\n4:Four\n5:No
Ball/Wide/LB/B+4\n6:Six\n7;No Ball+6\n8:Wicket\n");
break;
/* ***check whether*** */
case 2:
system("cls");
printf("\n\t\
t==================================================================================
==============\n\t\t\t\t\tCHECK WHEATHER\n\t\
t==================================================================================
==============\n\n");
float Temp;
printf("ENTER THE TEMPERATURE:\n");
scanf("%f",&Temp);
if(Temp<10)
{
printf("CANNOT PLAY\n");
exit(0);
}
else
{
printf("GOOD LUCK FOR THE MATCH\n");
}
break;
/* ***selection of teams** */
case 3:
system("cls");
/* ***MAIN MATCH****/
FILE *fp;
printf("Enter the filename to be opened with date(match 12-07-20)\n");
scanf("%s",filename);
fp = fopen(filename,"ab+");
//int b1=1;
//int b2=1;
//int sum1=0;
//int sum2=0;
//int w1=0;
//int w2=0;
int r1;
int r2;
setcolor(17);
if(fp == NULL){
MessageBox(0,"Error in Opening file\nMake sure your file is not write
protected","Warning",0);
}else{
printf("%s innings:\n",t1);
fprintf(fp,"%s innings:\n",t1);
while(b1<=120)
{
}
printf("%s requires %d runs to win in 120 balls at a run rate of %d\
n",t2,sum1+1,(sum1+1)/20);
}
}
else if(r2>8)
{
printf("invalid no.\n please read the instructions carefully\n");
continue;
}
else if(r2==7)
{
printf("free hit so no wicket will be considered even if wicket falls\
n");
b2--;
sum2=sum2+r2;
}
else
{
sum2=sum2+r2;
}
b2++;
}
a: if(sum2==sum1)
{
FILE *fp;
char filename[15];
printf("Enter the filename to be opened with date(match 12-07-20)\n");
scanf("%s", filename);
fp = fopen(filename,"ab+");
int b1=1;
int b2=1;
int sum1=0;
int sum2=0;
int w1=0;
int w2=0;
int r1;
int r2;
setcolor(17);
if(fp == NULL){
MessageBox(0,"Error in Opening file\nMake sure your file is not write
protected","Warning",0);
}else
{
printf("%s innings:\n",t1);
fprintf(fp,"%s innings:\n",t1);
printf("Let's Begin Super Over\n");
fprintf(fp,"Let's Begin Super Over\n");
printf("%s innings\n",t1);
while(b1<=6)
{
printf("status of ball %d:",b1);
fprintf(fp,"status of ball %d:",b1);
scanf("%d",&r1);
fprintf(fp,"%d\n",r1);
if(r1==8)
{
w1++;
if(w1==1)
{
printf("%s loses a wicket,one wicket remaining\n",t1);
}
if(w1==2)
{
printf("%s innings has came to an end\n",t1);
printf("%s requires %d runs to win in 6 balls at a run rate of
%d\n",t2,sum1+1,sum1+1);
break;
}
}
else if(r1>8)
{
printf("invalid no.\n please read the instructions carefully\
n");
continue;
}
else if(r1==7)
{
printf("free hit\n");
b1--;
sum1=sum1+r1;
}
else
{
sum1=sum1+r1;
}
b1++;
}
}
b1=b1-1;
fprintf(fp,"%s requires %d runs to win in 6 balls at a run rate of %d\
n",t2,sum1+1,(sum1+1)/20);
printf("%s innings\n",t2);
fprintf(fp,"%s innings:\n",t2);
while(b2<=6 && sum2<=sum1)
{
printf("status of ball %d:",b2);
fprintf(fp,"status of ball %d:",b2);
scanf("%d",&r2);
fprintf(fp,"%d\n",r2);
if(r2==8)
{ w2++;
if(w2==1)
{
printf("%s loses a wicket, one wicket remaining\n",t2);
}
if(w2==2)
{
printf("%s innings has come to an end\n",t2);
break;
}
}
else if(r2>8)
{
printf("invalid no.\nplease carefully read the instructions\n");
continue;
}
else if(r2==7)
{
printf("free hit so no wicket will be considered even if wicket
falls.Hence do not enter 8\n");
b2--;
sum2=sum2+r2;
}
else
{
sum2=sum2+r2;
}
b2++;
}
b2=b2-1;
printf("A total: %d\n",sum1);
fprintf(fp,"%s total is %d\n",t1,sum1);
printf("B total:%d\n",sum2);
fprintf(fp,"%s total is %d\n",t2,sum2);
if(sum1>sum2)
{
printf("%s won over %s by %d wickets in %d balls\n",t1,t2,w1,b1);
fprintf(fp,"%s won the match over %s by %d wickets in %d balls\
n",t1,t2,w1,b1);
}
if(sum1<sum2)
{
printf("%s won over %s by %d wickets in %d balls\n",t2,t1,w2,b2);
fprintf(fp,"%s won the match over %s by %d wickets in %d balls\
n",t2,t1,w2,b2);
}
if(sum1==sum2)
{
goto a;
}
fclose(fp);
break;
}
case 4:
system("cls");
printf("\n\t\
t==================================================================================
==============\n\t\t\t\t\tPREVIOUS MATCH DETAILS\n\t\
t==================================================================================
==============\n\n");
FILE *fptr;
char filename1[100];
char c;
// Open file
fptr= fopen(filename1, "r");
if (fptr == NULL)
{
printf("Cannot open file \n");
exit(0);
}
fclose(fptr);
break;
/* ***BAR GRAPH OF TWO TEAMS*** */
case 5:
system("cls");
printf("\n\t\
t==================================================================================
==============\n\t\t\t\t\tBAR GRAPH\n\t\
t==================================================================================
==============\n\n");
// gm is Graphics mode which is
// a computer display mode that
// generates image using pixels.
// DETECT is a macro defined in
// "graphics.h" header file
// location of sides
int left, top, right, bottom;
// y axis line
setcolor(45);
outtextxy(90,70,"SCORES");
line(100, 20, 100, 350);
settextstyle(10,0,3);
// x axis line
line(100, 350, 500, 350);
outtextxy(490,390,"INNINGS");
getch();
printf("INVALID CHOICE");
break;*/
}
printf("\n\n\n..::ENTER THE CHOICE:\n\n\t[1] MAIN MENU\t\t[0] EXIT\n");
scanf("%d",&ch);
switch (ch)
{
case 1:
goto main;
case 0:
break;
default:
printf("INVALID CHOICE");
break;
return 0;