Sie sind auf Seite 1von 3

import java.io.

*;
class batsman
{
String name,out,type;
int runs;
public batsman(String n)
{
name=n;
runs=0;
out="No";
type="-----";
}
public void displaydata()
{
System.out.println(name+"\t"+runs+"\t\t"
+out+"\t\t"+type);
}
}

class bowler
{
String name;
int over,maiden,runs,wicket,balls;
public bowler(String n)
{
name=n;
balls=0;
over=0;
maiden=0;
runs=0;
wicket=0;
}
public void displaydata()
{
System.out.println(name+"\t\t"+over+"."+
balls+"\t\t"+maiden+"\t\t"+runs+"\t\t"+
wicket);
}
}

public class cricket


{
DataInputStream x= new DataInputStream(System.in);
batsman bat[]={new batsman("SACHIN TENDULKAR"),
new batsman("VIRENDRA SHEWAG "),
new batsman("SOURAV GANGULY "),
new batsman("RAHUL DRAVID "),
new batsman("V. V. S. LAXMAN "),
new batsman("YUVRAJ SINGH "),
new batsman("MOHAMMAD KAIF "),
new batsman("IRFAN PATHAN "),
new batsman("L. BALAJI "),
new batsman("AJIT AGARKAR "),
new batsman("HARBHAJAN SINGH ")};
bowler bow[]={new bowler("SHOAIB AKHTAR"),
new bowler("MD. SAMI "),
new bowler("SHABBIR AHMED"),
new bowler("ABDUR RAZZAQ "),
new bowler("SHOAIB MALIK ")};
private void scorecard()
{
System.out.println("\t:: Scorecard for Batsman ::");
System.out.println("No.\tBatsman Name\t\tRuns\t\tOut\t\tType");
for(int i=0;i<bat.length;i++)
{
System.out.print((i+1)+"\t");
bat[i].displaydata();
}
System.out.println("\t:: Bowler Statistics ::");
System.out.println("No.\tBowler Name\t\tOvers\t\tMaiden\t\tRuns\t\tWicket");
for(int i=0;i<bow.length;i++)
{
System.out.print((i+1)+"\t");
bow[i].displaydata();
}
System.out.println("=========================================");
}
public void main() throws IOException
{
String cont="y",out,type;
int i,j,n1,n2,runs;
while(cont.equals("Y") || cont.equals("y"))
{
int tot=0;
scorecard();
System.out.print("Choose a Bowler No. : ");
n2=Integer.parseInt(x.readLine());
for(int b=0;b<6;b++)
{
System.out.println("Bowler throw "+(b+1)+" ball");
System.out.print("Enter Batsman No. : ");
n1=Integer.parseInt(x.readLine());
System.out.print("Runs Made by Batsman (0-6): ");
runs=Integer.parseInt(x.readLine());
System.out.print("Out? (Yes/No): ");
out=x.readLine();
if(out.equals("Yes"))
{
bat[n1-1].out="Yes";
System.out.print("Type of Out? (R/O,C&B,B,St,lbw): ");
type=x.readLine();
bat[n1-1].type=type;
bow[n2-1].wicket++;
}
bat[n1-1].runs+=runs;
bow[n2-1].runs+=runs;
bow[n2-1].balls=(b+1);
scorecard();
tot+=runs;
}
bow[n2-1].over++;
bow[n2-1].balls=0;
if(tot==0)
{
System.out.println("Maiden Over by Bowler");
bow[n2-1].maiden++;
}
else
System.out.println("Over Finish Runs given : "+tot);
scorecard();
System.out.print("Want to Play Next Over? (Y/N) : ");
cont=x.readLine();
}
}
}

Das könnte Ihnen auch gefallen