You are on page 1of 9

import java.util.

*;
class CricketMania // starting class
{
void main() // starting main method
{
Scanner Sc=new Scanner(System.in);
String name; // declaring variables
int aa;
int ii;
int bb;
int dd;
double rr;
int cheat;
int score1;
int score2;
int c;
int ch1;
int ch2;
int ch3;
int ch4;
int ch5;
int infinity=1;
System.out.println("========================================"); // print
statement
System.out.println("|| W E L C O M E T O T H E G A M E ||"); // print
statement
System.out.println("========================================"); // print
statement
for(c=0;c<4;c++) // for loop
System.out.println(""); // print statement
System.out.println("Enter your name."); // print statement
name=Sc.nextLine(); // input statement
while(infinity>0) // starting while loop
{
aa=0; // initialising variables
ii=0;
bb=0;
dd=0;
rr=0.0;
cheat=0;
score1=0;
score2=0;
c=0;
ch1=0;
ch2=0;
ch3=0;
ch4=0;
ch5=0;
infinity=1;
System.out.print("Welcome, "+name+"!"); // print statement
for(c=0;c<4;c++) // for loop
System.out.println(""); // print statement
System.out.println("Enter any number to proceed."); // print statement
ch1=Sc.nextInt(); // input statement
for(c=0;c<4;c++) // for loop
System.out.println(""); // print statement
if(ch1>=0) // starting if statement
{
for(c=0;c<4;c++) // for loop
System.out.println(""); // print statement
for(c=0;c<10;c++) // for loop to delay
{
for(dd=0;dd<=99999999;dd++)
{
}
}
System.out.print("L O A D I N G "); // print statement
for(c=0;c<10;c++) // for loop to delay execution time
{
for(dd=0;dd<=99999999;dd++)
{
}
System.out.print(". "); // print statement
}
System.out.println('\f'); // clear screen escape sequence
System.out.println("Hello,"+name+"!"); // print statement
System.out.println("");
System.out.println("Welcome to Cricket Mania.");
System.out.println("");
System.out.println("This game is pretty simple, really.");
System.out.println("");
System.out.println("Let's go through the rules.");
for(c=0;c<4;c++) // for loop
System.out.println(""); // print statement
for(c=0;c<10;c++) // for loops to delay execution time
{
for(dd=0;dd<=99999999;dd++)
{
}
}
for(c=0;c<10;c++)
{
for(dd=0;dd<=99999999;dd++)
{
}
}
for(c=0;c<10;c++)
{
for(dd=0;dd<=99999999;dd++)
{
}
}
for(c=0;c<10;c++)
{
for(dd=0;dd<=99999999;dd++)
{
}
}
for(c=0;c<10;c++)
{
for(dd=0;dd<=99999999;dd++)
{
}
}
for(c=0;c<10;c++)
{
for(dd=0;dd<=99999999;dd++)
{
}
}
System.out.print("L O A D I N G "); // print statement
for(c=0;c<10;c++) // for loop to delay execution time
{
for(dd=0;dd<=99999999;dd++)
{
}
System.out.print(". "); // print statement
}
for(c=0;c<10;c++)
{
for(dd=0;dd<=99999999;dd++)
{
}
}
for(c=0;c<10;c++)
{
for(dd=0;dd<=99999999;dd++)
{
}
}
for(c=0;c<10;c++)
{
for(dd=0;dd<=99999999;dd++)
{
}
}
for(c=0;c<10;c++)
{
for(dd=0;dd<=99999999;dd++)
{
}
}for(c=0;c<10;c++)
{
for(dd=0;dd<=99999999;dd++)
{
}
}for(c=0;c<10;c++)
{
for(dd=0;dd<=99999999;dd++)
{
}
}
System.out.println('\f'); // clear screen escape sequence
System.out.println("======================="); // print statement
System.out.println("|| R U L E S ||");
System.out.println("=======================");
System.out.println("");
System.out.println("-> This game is pretty similar to the hand cricket
game played by kids.");
System.out.println("");
System.out.println("-> There is no specific limit to the number of
balls.");
System.out.println("");
System.out.println("-> You will be playing against the computer as your
opponent.");
System.out.println("");
System.out.println("-> You will bat first.");
System.out.println("");
System.out.println("-> You are allowed to enter any number from 1 to
10.");
System.out.println("");
System.out.println("-> Enter the numbers carefully, without making any
mistake.");
System.out.println("");
System.out.println("-> If the number entered by the computer is the
same as");
System.out.println(" the number entered by you, you will be declared
as out.");
System.out.println("");
System.out.println("-> Your final score will be the sum of the numbers
you had");
System.out.println(" entered before being declared as out.");
System.out.println("");
System.out.println("-> After you are declared as out, you will have to
bowl.");
System.out.println(" This time around, the computer shall be
batting.");
System.out.println("");
System.out.println("-> Try your best to enter the same number, as the
one");
System.out.println(" that has been entered by the computer.");
System.out.println("");
System.out.println("-> If the sum of the numbers entered by the
computer is greater");
System.out.println(" than your final score, the computer will win.");
System.out.println("");
System.out.println("-> However, if the sum of the numbers entered by
you is greater");
System.out.println(" than the computer's final score, you will
win!");
System.out.println("");
System.out.println("Good luck!:D");
System.out.println("May the odds be ever in your favour.");
System.out.println("");
System.out.println("");
System.out.println("Ready? Let's go!");
System.out.println("Enter any number to begin.");
ch2=Sc.nextInt(); // input statement
if(ch2>=0) // starting if statement
{
System.out.println('\f'); // clear screen escape sequence
for(c=0;c<3;c++) // for loop
System.out.println("========================================"); //
print statement
System.out.println(""); // print statement
System.out.println("| Y O U A R E B A T T I N G N O W |");
System.out.println("");
for(c=0;c<3;c++) // for loop
System.out.println("========================================"); //
print statement
for(ii=1;ii>0;ii++) // starting for loop
{
System.out.println(""); // print statement
System.out.print("Enter a number.");
bb=Sc.nextInt(); // input statement
rr=((Math.random())*10); // generating a random real number
rr=rr+1; // calculating
aa=(int)(rr); // converting real number to whole number
System.out.println(""); // print statement
System.out.println("Computer's number: "+aa);
System.out.println("");
System.out.println("____________________________");
System.out.println("");
if(bb==aa) // if-else-if construct
{
System.out.println(""); // print statement
System.out.println("YIKES! You're out!");
System.out.println("");
System.out.println("");
System.out.println("Your final score is "+score1+".");
System.out.println("");
break; // break statement
}
else if(bb>0&&bb<=10)
score1=score1+bb; // calculating
else if(bb>10||bb<=0)
{
System.out.println("GAME OVER! You have either tried to"); //
print statement
System.out.println("cheat or have entered a wrong number.");
cheat++; // using increment operator
break; // break statement
}
System.out.println("Your current score is "+score1+"."); // print
statement
System.out.println("");
System.out.println("____________________________");
} // closing for loop
for(c=0;c<4;c++) // for loop
System.out.println(""); // print statement
System.out.println("Enter any number to continue."); // print
statement
ch3=Sc.nextInt(); // input statement
for(c=0;c<4;c++) // for loop
System.out.println(""); // print statement
if(ch3>=0) // starting if statement
{
for(c=0;c<10;c++) // for loops to delay execution time
{
for(dd=0;dd<=99999999;dd++)
{
}
}
for(c=0;c<10;c++)
{
for(dd=0;dd<=99999999;dd++)
{
}
}
for(c=0;c<10;c++)
{
for(dd=0;dd<=99999999;dd++)
{
}
}
for(c=0;c<10;c++)
{
for(dd=0;dd<=99999999;dd++)
{
}
}
System.out.print("L O A D I N G "); // print statement
for(c=0;c<10;c++) // for loop delay execution time
{
for(dd=0;dd<=99999999;dd++)
{
}
System.out.print(". "); // print statement
}
for(c=0;c<10;c++) // for loops to delay execution time
{
for(dd=0;dd<=99999999;dd++)
{
}
}
for(c=0;c<10;c++)
{
for(dd=0;dd<=99999999;dd++)
{
}
}
for(c=0;c<10;c++)
{
for(dd=0;dd<=99999999;dd++)
{
}
}
for(c=0;c<10;c++)
{
for(dd=0;dd<=99999999;dd++)
{
}
}
System.out.println('\f'); // clear screen escape sequence
for(c=0;c<3;c++) // for loop
System.out.println("========================================"); //
print statement
System.out.println("");
System.out.println("| Y O U A R E B O W L I N G N O W |");
System.out.println("");
for(c=0;c<3;c++) // for loop
System.out.println("========================================"); //
print statement
for(ii=1;ii>0;ii++) // starting for loop
{
System.out.println(""); // print statement
System.out.println("Enter a number.");
bb=Sc.nextInt(); // input statement
rr=((Math.random())*10); // generating random real number
rr=rr+1; // calculating
aa=(int)(rr); // converting real number to whole number
System.out.println(""); // print statement
System.out.println("Computer's number: "+aa);
System.out.println("");
System.out.println("____________________________");
System.out.println("");
if(aa==bb) // if-else-if construct
{
System.out.println(""); // print statement
System.out.println("Aaaand, the computer is out!");
System.out.println("");
System.out.println("");
System.out.println("The computer's final score is
"+score2+".");
System.out.println("");
System.out.println("");
break; // break statement
}
else if(bb>0&&bb<=10)
score2=score2+aa; // calculating
else if(bb>10||bb<=0)
{
System.out.println("GAME OVER! You have either tried
to"); // print statement
System.out.println("cheat or have entered a wrong
number.");
cheat++; // using increment operator
break; // break statement
}
System.out.println("The computer's current score is "+score2+".");
// print statement
System.out.println("");
System.out.println("____________________________");
} // closing for loop
for(c=0;c<4;c++) // for loop
System.out.println(""); // print statement
for(c=0;c<4;c++) // for loop
System.out.println(""); // print statement
System.out.println("Enter any number to view the results."); //
print statement
ch4=Sc.nextInt(); // input statement
if(ch4>=0) // starting if statement
{
for(c=0;c<4;c++) // for loop
System.out.println(""); // print statement
for(c=0;c<10;c++) // for loops to delay execution time
{
for(dd=0;dd<=99999999;dd++)
{
}
}
for(c=0;c<10;c++)
{
for(dd=0;dd<=99999999;dd++)
{
}
}
for(c=0;c<10;c++)
{
for(dd=0;dd<=99999999;dd++)
{
}
}
for(c=0;c<10;c++)
{
for(dd=0;dd<=99999999;dd++)
{
}
}
System.out.print("L O A D I N G "); // print statement
for(c=0;c<10;c++) // for loop to delay execution time
{
for(dd=0;dd<=99999999;dd++)
{
}
System.out.print(". "); // print statement
}
for(c=0;c<10;c++) // for loops to delay execution time
{
for(dd=0;dd<=99999999;dd++)
{
}
}
for(c=0;c<10;c++)
{
for(dd=0;dd<=99999999;dd++)
{
}
}
for(c=0;c<10;c++)
{
for(dd=0;dd<=99999999;dd++)
{
}
}
for(c=0;c<10;c++)
{
for(dd=0;dd<=99999999;dd++)
{
}
}
for(c=0;c<4;c++) // for loop
System.out.println(""); // print statement
for(ii=0;ii<1;ii++) // starting for loop
{
System.out.println('\f'); // clear screen escape sequence
System.out.println("____________________________"); // print
statement
System.out.println("");
System.out.println("========================================");
System.out.println("");
System.out.println("Your final score is "+score1+".");
System.out.println("The computer's final score is "+score2+".");
System.out.println("");
System.out.println("========================================");
System.out.println("");
System.out.println("____________________________");
for(c=0;c<4;c++) // for loop
System.out.println(""); // print statement
if((score1)>(score2)) // if-else-if construct
System.out.println("CONGRATULATIONS! You have defeated the
almighty computer! :D"); // print statement
else if((score1)<(score2))
System.out.println("Aw, no! The computer has defeated you! :
("); // print statement
else if(score1==score2)
System.out.println("It seems that we have a tie here."); //
print statement
} // closing for loop
for(c=0;c<4;c++) // for loop
System.out.println(""); // print statement
System.out.println("____________________________"); // print statement
System.out.println("");
System.out.println("Enter 1 to play again.");
System.out.println("");
System.out.println("Enter 0 or any other number to quit.");
ch5=Sc.nextInt(); // input statement
if(ch5==1) // if-else construct
System.out.print('\f'); // clear screen escape sequence
else
{
System.out.print('\f'); // clear screen escape sequence
System.out.println("Goodbye! We hope to see you soon! :D"); //
print statement
break; // break statement
}
} // closing if statement
} // closing if statement
} // closing if statement
} // closing if statement
} // closing while loop
} // closing main method
} // closing class

You might also like