A text Cricket game in java with different functions for choosing team, opponent, over, toss, batting and bowling. Uses Random class of Java and JCF (Java Collection Framework)
This is a program for a text Cricket game in Java.
1.) Here we have used 6 different functions for choosing player's team, opponent team, overs, toss, batting and bowling (apart from main()).
2.) The simple rule for the game is that, while bowling or batting, user inputs a no. and computer takes out a number.
3.) The computer-generated number uses Random class of Java (both player and Computer's number being between 1-6).
4.) If both the numbers are same then whoever is on the batting side, loses a wicket. We and Computer both have 3 wickets in total.
5.) The program also displays things like Current Run Rate, Required Run Rate, and implements wide/byes (in case the user takes out a no other than 1-6 while bowling).
6.) It uses Java Collection Framework for different purposes, like storing team names on the very simple end and for storing user's input while batting on a bit trickier end. The latter one useful when the user is trying to consecutively take out the same no., hence take a wicket.
7.) For overs there is a choice among 1,3 5 and 10 overs.
8.) Also while batting if the user takes out a number other 1-6 it asks him to reface the ball. While bowling if user takes out a number other than 1-6 it adds run according to a randomized choice between wide and byes (JCF used for storing integers 1 (wide) and 4 (byes) and Random class used for choosing one among them, hence a randomized choice).
Submitted by Kaustubh Srivastava (kaustubhSrv)
Download packets of source code on Coders Packet