public static int TossCall(string Team1_Name, string Team2_Name, string Team1_Captain, string Team2_Captain) { int TossValue = 0; Console.WriteLine("Great, lets move for the TOSS \n"); Console.WriteLine("We would be like to ask from " + Team1_Name + " Captain " + Team1_Captain + " .... Heads or Tails"); Console.WriteLine("[0] = TRAILS"); Console.WriteLine("[1] = HEADS \n"); do { TossValue = Convert.ToInt32(Console.ReadLine()); if (TossValue > 1) { Console.WriteLine("Invalid Code, Please enter [0] = TRAILS or [1] = HEADS"); } } while (TossValue > 1); int Toss_Win_Result = Toss.TossDesider(TossValue, Team1_Name, Team2_Name, Team1_Captain, Team2_Captain); return(Toss_Win_Result); }
static void Main(string[] args) { int[] Team_First_BattingLine = new int[11]; //Store the FIRST batting team runs int[] Team_Second_BattingLine = new int[11]; //Store the SECOND batting team runs int[] Team1_BowlingLine = new int[11]; int[] Team2_BowlingLine = new int[11]; int[] Boundary_Batting1 = new int[2]; Boundary_Batting1[0] = 0; //Counting FOURs Boundary_Batting1[1] = 0; //Counting SIXs int[] Boundary_Batting2 = new int[2]; Boundary_Batting2[0] = 0; //Counting FOURs Boundary_Batting2[1] = 0; //Counting SIXs int Batsman1 = 0; int Batsman2 = 0; int Stricker = 1; //TO handle the Batsman Strike int WhiteBowled_Team1 = 0; int WhiteBowled_Team2 = 0; int BatsmanMaxCode = 1; int wicketFallsTeam1 = 0; int wicketFallsTeam2 = 0; int MatchOvers = 1; //T20 match total balls (6 * 20 = 120) int TotalBalls_FirstInnings = MatchOvers * 6; //Total balls avaiable --- First Innings int TotalBalls_SecondInnings = MatchOvers * 6; //Total balls avaiable --- Second Innings int TotalBalls_Fixed = MatchOvers * 6; //Decrearing this variable to run the complete total balls (FOR LOOP) int BallBowl = 0; //Counting Valid Balls int Score1 = 0, Score2 = 0; //Counting Score for FirstBatting and Second Batting int Current_Bowler = 0; //Presentation Spash ----- START Console.WriteLine(" ÛÛÛÛÛÛÛÛÛ ÛÛÛ ÛÛÛÛÛ ÛÛÛÛÛ "); Console.WriteLine(" ÛÛÛ°°°°°ÛÛÛ °°° °°ÛÛÛ °°ÛÛÛ "); Console.WriteLine(" Û ÛÛ °°° ÛÛÛÛÛÛÛÛ ÛÛÛÛ ÛÛÛÛÛÛ °ÛÛÛ ÛÛÛÛÛ ÛÛÛÛÛÛ ÛÛÛÛÛÛÛ "); Console.WriteLine("° ÛÛÛ °°ÛÛÛ°°ÛÛÛ°°ÛÛÛ ÛÛÛ°°ÛÛÛ °ÛÛÛ°°ÛÛÛ ÛÛÛ°°ÛÛÛ°°°ÛÛÛ° "); Console.WriteLine("° ÛÛÛ °ÛÛÛ °°° °ÛÛÛ °ÛÛÛ °°° °ÛÛÛÛÛÛ° °ÛÛÛÛÛÛÛ °ÛÛÛ "); Console.WriteLine(" °°ÛÛÛ ÛÛÛ °ÛÛÛ °ÛÛÛ °ÛÛÛ ÛÛÛ °ÛÛÛ°°ÛÛÛ °ÛÛÛ°°° °ÛÛÛ ÛÛÛ"); Console.WriteLine(" °°ÛÛÛÛÛÛÛÛÛ ÛÛÛÛÛ ÛÛÛÛÛ°°ÛÛÛÛÛÛ ÛÛÛÛ ÛÛÛÛÛ°°ÛÛÛÛÛÛ °°ÛÛÛÛÛ "); Console.WriteLine(" °°°°°°°°° °°°°° °°°°° °°°°°° °°°° °°°°° °°°°°° °°°°° "); Console.WriteLine("\t"); Console.WriteLine(" ÛÛÛÛÛ ÛÛÛ "); Console.WriteLine(" °°ÛÛÛ °°° "); Console.WriteLine(" °ÛÛÛ ÛÛÛÛ ÛÛÛÛÛ ÛÛÛÛÛ ÛÛÛÛÛÛ "); Console.WriteLine(" °ÛÛÛ °°ÛÛÛ °°ÛÛÛ °°ÛÛÛ ÛÛÛ°°ÛÛÛ"); Console.WriteLine(" °ÛÛÛ °ÛÛÛ °ÛÛÛ °ÛÛÛ °ÛÛÛÛÛÛÛ "); Console.WriteLine(" °ÛÛÛ Û °ÛÛÛ °°ÛÛÛ ÛÛÛ °ÛÛÛ°°° "); Console.WriteLine(" ÛÛÛÛÛÛÛÛÛÛÛ ÛÛÛÛÛ °°ÛÛÛÛÛ °°ÛÛÛÛÛÛ "); Console.WriteLine(" °°°°°°°°°°° °°°°° °°°°° °°°°°° "); Console.WriteLine("\t"); //Presentation Spash ----- END string[] tdarr = { "PAKISTAN", "SRILANKA", "AUSTRALIA", "INDIA" }; // Team Details Array string[,] AllTeamsPlayer = new string[4, 11]; // Team PAKISTAN 11 Players ==== CODE == 0 // 0 = TEEAM ----- 0 = TeamPlayer AllTeamsPlayer[0, 0] = "Sarfraz Ahmed(c)"; AllTeamsPlayer[0, 1] = "Fakhar Zaman"; AllTeamsPlayer[0, 2] = "Azhar Ali"; AllTeamsPlayer[0, 3] = "Babar Azam"; AllTeamsPlayer[0, 4] = "Fahim Ashraf"; AllTeamsPlayer[0, 5] = "Hasan Ali"; AllTeamsPlayer[0, 6] = "Imad Wasim"; AllTeamsPlayer[0, 7] = "Junaid Khan"; AllTeamsPlayer[0, 8] = "Mohammad Amir"; AllTeamsPlayer[0, 9] = "Mohammad Hafeez"; AllTeamsPlayer[0, 10] = "Shadab Khan"; // Team SRILANKA 11 Players ==== CODE == 1 AllTeamsPlayer[1, 0] = "MA Aponso"; AllTeamsPlayer[1, 1] = "PVD Chameera"; AllTeamsPlayer[1, 2] = "LD Chandimal"; AllTeamsPlayer[1, 3] = "A Dananjaya"; AllTeamsPlayer[1, 4] = "DM de Silva"; AllTeamsPlayer[1, 5] = "PC de Silva"; AllTeamsPlayer[1, 6] = "PWH de Silva"; AllTeamsPlayer[1, 7] = "N Dickwella"; AllTeamsPlayer[1, 8] = "AM Fernando"; AllTeamsPlayer[1, 9] = "N Pradeep"; AllTeamsPlayer[1, 10] = "DAS Gunaratne"; // Team AUSTRALIA 11 Players ==== CODE == 2 AllTeamsPlayer[2, 0] = "GJ Bailey"; AllTeamsPlayer[2, 1] = "SM Boland"; AllTeamsPlayer[2, 2] = "NM Coulter-Nile"; AllTeamsPlayer[2, 3] = "PJ Cummins"; AllTeamsPlayer[2, 4] = "JP Faulkner"; AllTeamsPlayer[2, 5] = "AJ Finch"; AllTeamsPlayer[2, 6] = "PSP Handscomb"; AllTeamsPlayer[2, 7] = "JW Hastings"; AllTeamsPlayer[2, 8] = "JR Hazlewood"; AllTeamsPlayer[2, 9] = "TM Head"; AllTeamsPlayer[2, 10] = "SD Heazlett"; // Team INDIA 11 Players ==== CODE == 3 AllTeamsPlayer[3, 0] = "Virat Kohli(c)"; AllTeamsPlayer[3, 1] = "Rohit Sharma"; AllTeamsPlayer[3, 2] = "Shikhar Dhawan"; AllTeamsPlayer[3, 3] = "Yuvraj Singh"; AllTeamsPlayer[3, 4] = "Ajinkya Rahane"; AllTeamsPlayer[3, 5] = "Dinesh Karthik"; AllTeamsPlayer[3, 6] = "Kedar Jadhav"; AllTeamsPlayer[3, 7] = "MS Dhoni"; AllTeamsPlayer[3, 8] = "Hardik Pandya"; AllTeamsPlayer[3, 9] = "Ravichandran Ashwin"; AllTeamsPlayer[3, 10] = "Ravindra Jadeja"; int[] tsarr = new int[2]; // Team Selected Array --- USER INPUT Console.WriteLine("Please select Team1 and Team2 using their mentioned codes:"); for (int i = 0; i < tdarr.Length; i++) { Console.WriteLine("[" + i + "] = " + tdarr[i]); } Console.WriteLine("-----------------------------------------------------------"); Console.Write(""); tsarr[1] = 4654354; for (int i = 0; i < 2; i++) { Console.Write("Please Enter the number for Team Selection Team" + (i + 1) + " :"); tsarr[i] = Convert.ToInt32(Console.ReadLine()); do { if (tsarr[i] > 3 || tsarr[0] == tsarr[1]) { Console.WriteLine("INVALID CODE: "); tsarr[i] = Convert.ToInt32(Console.ReadLine()); } } while (tsarr[i] > 3); } Console.WriteLine("\n"); Console.WriteLine("The match will begin soon between " + tdarr[tsarr[0]] + " VS " + tdarr[tsarr[1]]); Console.WriteLine("\n"); //Store the team1 and team2 name in 2 string variables for easy use string Team1_Name = tdarr[tsarr[0]]; string Team2_Name = tdarr[tsarr[1]]; //Store the team1 and team2 Code in 2 integar variables for easy use int Team1_Code = tsarr[0]; int Team2_Code = tsarr[1]; Display d = new Display(); d.ShowTeamPlayers(Team1_Code, AllTeamsPlayer, Team1_Name); //This function displays the TEAM1 players d.ShowTeamPlayers(Team2_Code, AllTeamsPlayer, Team2_Name); //This function displays the TEAM2 players int Checking_Toss_Win = Toss.TossCall(Team1_Name, Team2_Name, AllTeamsPlayer[Team1_Code, 0], AllTeamsPlayer[Team2_Code, 0]); d.ShowTeamPlayers(Team1_Code, AllTeamsPlayer, Team1_Name); //This function displays the TEAM1 players d.ShowTeamPlayers(Team2_Code, AllTeamsPlayer, Team2_Name); //This function displays the TEAM2 players int[] SelectedBatBowl = MatchAction.BowlerSelectionInningStart(Checking_Toss_Win, Current_Bowler, Team1_Name, Team2_Name, Team1_Code, Team2_Code, AllTeamsPlayer); int TeamBatting_Code = SelectedBatBowl[0]; //First Batting Team Code int Battman_1_Code = SelectedBatBowl[1]; //BATSMAN1 Code int Battman_2_Code = SelectedBatBowl[2]; //BATSMAN2 Code int TeamBowling_Code = SelectedBatBowl[3]; //First BOWLING Team Code int Team_Bowler_Code = SelectedBatBowl[4]; //First BOWLER Current_Bowler = Team_Bowler_Code; for (int i = 1; i <= TotalBalls_Fixed; i++) { if (wicketFallsTeam1 < 9) { Display.ShowCodes(); // This method shows the Codes for activity int Action_Input = Convert.ToInt32(Console.ReadLine()); do { if (Action_Input > 9) { Console.WriteLine("INVALID CODE!!! "); Display.ShowCodes(); // This method shows the Codes for activity Action_Input = Convert.ToInt32(Console.ReadLine()); } } while (Action_Input > 8); if (Action_Input == 0) { Score1 = Score1 + 0; //Adding 0 in Total Score TotalBalls_FirstInnings = --TotalBalls_FirstInnings; //Decrease 1 ball from total balls BallBowl = BallBowl + 1; if (Stricker == 1) { //Batsman1 = Batsman1 + 0; Team_First_BattingLine[Battman_1_Code] = Team_First_BattingLine[Battman_1_Code] + 0; if (BallBowl % 6 == 0) { Stricker = 0; MatchAction.ShowBowlers(tdarr[TeamBowling_Code], TeamBowling_Code, AllTeamsPlayer); Current_Bowler = Convert.ToInt32(Console.ReadLine()); } } else if (Stricker == 0) { //Batsman2 = Batsman2 + 0; Team_First_BattingLine[Battman_2_Code] = Team_First_BattingLine[Battman_2_Code] + 0; /*Batsman2 Transfering the strike to Batsman1 after OVER completion*/ if (BallBowl % 6 == 0) { Stricker = 1; //Show the Bowler list for next over selection MatchAction.ShowBowlers(tdarr[TeamBowling_Code], TeamBowling_Code, AllTeamsPlayer); Current_Bowler = Convert.ToInt32(Console.ReadLine()); } } Display.ShowScore(TeamBatting_Code, BallBowl, Score1, wicketFallsTeam1); } else if (Action_Input == 1) { Score1 = Score1 + 1; //Adding 0 in Total Score TotalBalls_FirstInnings = --TotalBalls_FirstInnings; //Decrease 1 ball from total balls BallBowl = BallBowl + 1; if (Stricker == 1) { //Batsman1 = Batsman1 + 1; Team_First_BattingLine[Battman_1_Code] = Team_First_BattingLine[Battman_1_Code] + 1; Stricker = 0; /*Batsman1 Transfering the strike to Batsman2 after OVER completion*/ if (BallBowl % 6 == 0) { Stricker = 1; //Show the Bowler list for next over selection MatchAction.ShowBowlers(tdarr[TeamBowling_Code], TeamBowling_Code, AllTeamsPlayer); Current_Bowler = Convert.ToInt32(Console.ReadLine()); } } else if (Stricker == 0) { //Batsman2 = Batsman2 + 1; Team_First_BattingLine[Battman_2_Code] = Team_First_BattingLine[Battman_2_Code] + 1; Stricker = 1; /*Batsman2 Transfering the strike to Batsman1 after OVER completion*/ if (BallBowl % 6 == 0) { Stricker = 0; //Show the Bowler list for next over selection MatchAction.ShowBowlers(tdarr[TeamBowling_Code], TeamBowling_Code, AllTeamsPlayer); Current_Bowler = Convert.ToInt32(Console.ReadLine()); } } Display.ShowScore(TeamBatting_Code, BallBowl, Score1, wicketFallsTeam1); } else if (Action_Input == 2) { Score1 = Score1 + 2; //Adding 0 in Total Score TotalBalls_FirstInnings = --TotalBalls_FirstInnings; //Decrease 1 ball from total balls BallBowl = BallBowl + 1; if (Stricker == 1) { //Batsman1 = Batsman1 + 2; Team_First_BattingLine[Battman_1_Code] = Team_First_BattingLine[Battman_1_Code] + 2; /*Batsman1 Transfering the strike to Batsman2 after OVER completion*/ if (BallBowl % 6 == 0) { Stricker = 0; //Show the Bowler list for next over selection MatchAction.ShowBowlers(tdarr[TeamBowling_Code], TeamBowling_Code, AllTeamsPlayer); Current_Bowler = Convert.ToInt32(Console.ReadLine()); } } else if (Stricker == 0) { //Batsman2 = Batsman2 + 2; Team_First_BattingLine[Battman_2_Code] = Team_First_BattingLine[Battman_2_Code] + 2; /*Batsman2 Transfering the strike to Batsman1 after OVER completion*/ if (BallBowl % 6 == 0) { Stricker = 1; //Show the Bowler list for next over selection MatchAction.ShowBowlers(tdarr[TeamBowling_Code], TeamBowling_Code, AllTeamsPlayer); Current_Bowler = Convert.ToInt32(Console.ReadLine()); } } Display.ShowScore(TeamBatting_Code, BallBowl, Score1, wicketFallsTeam1); } else if (Action_Input == 3) { //Adding 0 in Total Score Score1 = Score1 + 3; //Decrease 1 ball from total balls TotalBalls_FirstInnings = --TotalBalls_FirstInnings; BallBowl = BallBowl + 1; if (Stricker == 1) { //Batsman1 = Batsman1 + 3; Team_First_BattingLine[Battman_1_Code] = Team_First_BattingLine[Battman_1_Code] + 3; Stricker = 0; /*Batsman1 Transfering the strike to Batsman2 after OVER completion*/ if (BallBowl % 6 == 0) { Stricker = 1; //Show the Bowler list for next over selection MatchAction.ShowBowlers(tdarr[TeamBowling_Code], TeamBowling_Code, AllTeamsPlayer); Current_Bowler = Convert.ToInt32(Console.ReadLine()); } } else if (Stricker == 0) { //Batsman2 = Batsman2 + 3; Team_First_BattingLine[Battman_2_Code] = Team_First_BattingLine[Battman_2_Code] + 3; Stricker = 1; /*Batsman2 Transfering the strike to Batsman1 after OVER completion*/ if (BallBowl % 6 == 0) { Stricker = 0; //Show the Bowler list for next over selection MatchAction.ShowBowlers(tdarr[TeamBowling_Code], TeamBowling_Code, AllTeamsPlayer); Current_Bowler = Convert.ToInt32(Console.ReadLine()); } } Display.ShowScore(TeamBatting_Code, BallBowl, Score1, wicketFallsTeam1); } else if (Action_Input == 4) { //Adding 0 in Total Score Score1 = Score1 + 4; //Counting Boundary - 4 Boundary_Batting1[0] = Boundary_Batting1[0] + 1; //Decrease 1 ball from total balls TotalBalls_FirstInnings = --TotalBalls_FirstInnings; BallBowl = BallBowl + 1; if (Stricker == 1) { //Batsman1 = Batsman1 + 4; Team_First_BattingLine[Battman_1_Code] = Team_First_BattingLine[Battman_1_Code] + 4; /*Batsman1 Transfering the strike to Batsman2 after OVER completion*/ if (BallBowl % 6 == 0) { Stricker = 0; //Show the Bowler list for next over selection MatchAction.ShowBowlers(tdarr[TeamBowling_Code], TeamBowling_Code, AllTeamsPlayer); Current_Bowler = Convert.ToInt32(Console.ReadLine()); } } else if (Stricker == 0) { //Batsman2 = Batsman2 + 4; Team_First_BattingLine[Battman_2_Code] = Team_First_BattingLine[Battman_2_Code] + 4; /*Batsman2 Transfering the strike to Batsman1 after OVER completion*/ if (BallBowl % 6 == 0) { Stricker = 1; //Show the Bowler list for next over selection MatchAction.ShowBowlers(tdarr[TeamBowling_Code], TeamBowling_Code, AllTeamsPlayer); Current_Bowler = Convert.ToInt32(Console.ReadLine()); } } Display.ShowScore(TeamBatting_Code, BallBowl, Score1, wicketFallsTeam1); } else if (Action_Input == 5) { //Adding 0 in Total Score Score1 = Score1 + 5; //Decrease 1 ball from total balls TotalBalls_FirstInnings = --TotalBalls_FirstInnings; BallBowl = BallBowl + 1; if (Stricker == 1) { //Batsman1 = Batsman1 + 5; Team_First_BattingLine[Battman_1_Code] = Team_First_BattingLine[Battman_1_Code] + 5; Stricker = 0; /*Batsman1 Transfering the strike to Batsman2 after OVER completion*/ if (BallBowl % 6 == 0) { Stricker = 1; //Show the Bowler list for next over selection MatchAction.ShowBowlers(tdarr[TeamBowling_Code], TeamBowling_Code, AllTeamsPlayer); Current_Bowler = Convert.ToInt32(Console.ReadLine()); } } else if (Stricker == 0) { //Batsman2 = Batsman2 + 5; Team_First_BattingLine[Battman_2_Code] = Team_First_BattingLine[Battman_2_Code] + 5; Stricker = 1; /*Batsman2 Transfering the strike to Batsman1 after OVER completion*/ if (BallBowl % 6 == 0) { Stricker = 0; //Show the Bowler list for next over selection MatchAction.ShowBowlers(tdarr[TeamBowling_Code], TeamBowling_Code, AllTeamsPlayer); Current_Bowler = Convert.ToInt32(Console.ReadLine()); } } Display.ShowScore(TeamBatting_Code, BallBowl, Score1, wicketFallsTeam1); } else if (Action_Input == 6) { //Adding 0 in Total Score Score1 = Score1 + 6; //Counting Boundary - 6 Runs Boundary_Batting1[1] = Boundary_Batting1[1] + 1; //Decrease 1 ball from total balls TotalBalls_FirstInnings = --TotalBalls_FirstInnings; BallBowl = BallBowl + 1; if (Stricker == 1) { //Batsman1 = Batsman1 + 6; Team_First_BattingLine[Battman_1_Code] = Team_First_BattingLine[Battman_1_Code] + 6; /*Batsman1 Transfering the strike to Batsman2 after OVER completion*/ if (BallBowl % 6 == 0) { Stricker = 0; //Show the Bowler list for next over selection MatchAction.ShowBowlers(tdarr[TeamBowling_Code], TeamBowling_Code, AllTeamsPlayer); Current_Bowler = Convert.ToInt32(Console.ReadLine()); } } else if (Stricker == 0) { //Batsman2 = Batsman2 + 6; Team_First_BattingLine[Battman_2_Code] = Team_First_BattingLine[Battman_2_Code] + 6; /*Batsman2 Transfering the strike to Batsman1 after OVER completion*/ if (BallBowl % 6 == 0) { Stricker = 1; //Show the Bowler list for next over selection MatchAction.ShowBowlers(tdarr[TeamBowling_Code], TeamBowling_Code, AllTeamsPlayer); Current_Bowler = Convert.ToInt32(Console.ReadLine()); } } Display.ShowScore(TeamBatting_Code, BallBowl, Score1, wicketFallsTeam1); } else if (Action_Input == 7) //Batsman Out Conditions { //Adding 0 in Total Score Score1 = Score1 + 0; //Decrease 1 ball from total balls TotalBalls_FirstInnings = --TotalBalls_FirstInnings; BallBowl = BallBowl + 1; //Counting OUT/Wickets in Bowler array Team1_BowlingLine[Current_Bowler] = Team1_BowlingLine[Current_Bowler] + 1; if (Stricker == 1) { //Batsman1 = Batsman1 + 3; ++BatsmanMaxCode; ++wicketFallsTeam1; Battman_1_Code = BatsmanMaxCode; Stricker = 1; /*Batsman1 Transfering the strike to Batsman2 after OVER completion*/ if (BallBowl % 6 == 0) { Stricker = 0; //Show the Bowler list for next over selection MatchAction.ShowBowlers(tdarr[TeamBowling_Code], TeamBowling_Code, AllTeamsPlayer); Current_Bowler = Convert.ToInt32(Console.ReadLine()); } } else if (Stricker == 0) { //Batsman2 = Batsman2 + 3; ++BatsmanMaxCode; ++wicketFallsTeam1; Battman_2_Code = BatsmanMaxCode; Stricker = 0; /*Batsman2 Transfering the strike to Batsman1 after OVER completion*/ if (BallBowl % 6 == 0) { Stricker = 1; //Show the Bowler list for next over selection MatchAction.ShowBowlers(tdarr[TeamBowling_Code], TeamBowling_Code, AllTeamsPlayer); Current_Bowler = Convert.ToInt32(Console.ReadLine()); } } Display.ShowScore(TeamBatting_Code, BallBowl, Score1, wicketFallsTeam1); } else if (Action_Input == 8) { //Adding 1 in Total Score (WHITE BALL) Score1 = Score1 + 1; WhiteBowled_Team1 = WhiteBowled_Team1 + 1; } //Display.ShowScoreCard(Team_First_BattingLine, Team1_BowlingLine, Score1, Boundary_Batting1); } } Display.ShowScoreCard(Team_First_BattingLine, Team1_BowlingLine, Score1, Boundary_Batting1, AllTeamsPlayer, TeamBatting_Code, TeamBowling_Code); Team1_Name = tdarr[tsarr[0]]; Team2_Name = tdarr[tsarr[1]]; BallBowl = 0; //put = in BallBowl for second things. /* ------------------------- SECOND INNINGS -----------------------------*/ Console.WriteLine("SECOND INNINGS"); SelectedBatBowl = MatchAction.BowlerSelectionInningSecond(Current_Bowler, Team2_Name, Team1_Name, Team2_Code, Team1_Code, AllTeamsPlayer); TeamBatting_Code = SelectedBatBowl[0]; Battman_1_Code = SelectedBatBowl[1]; Battman_2_Code = SelectedBatBowl[2]; TeamBowling_Code = SelectedBatBowl[3]; Team_Bowler_Code = SelectedBatBowl[4]; Current_Bowler = Team_Bowler_Code; for (int i = 1; i <= TotalBalls_Fixed; i++) { if (Score1 < Score2) { break; } if (wicketFallsTeam2 < 9) { Display.ShowCodes(); // This method shows the Codes for activity int Action_Input = Convert.ToInt32(Console.ReadLine()); do { if (Action_Input > 9) { Console.WriteLine("INVALID CODE!!! "); Display.ShowCodes(); // This method shows the Codes for activity Action_Input = Convert.ToInt32(Console.ReadLine()); } } while (Action_Input > 8); if (Action_Input == 0) { Score2 = Score2 + 0; //Adding 0 in Total Score TotalBalls_SecondInnings = --TotalBalls_SecondInnings; //Decrease 1 ball from total balls BallBowl = BallBowl + 1; if (Stricker == 1) { //Batsman1 = Batsman1 + 0; Team_Second_BattingLine[Battman_1_Code] = Team_Second_BattingLine[Battman_1_Code] + 0; if (BallBowl % 6 == 0) { Stricker = 0; MatchAction.ShowBowlers(tdarr[TeamBowling_Code], TeamBowling_Code, AllTeamsPlayer); Current_Bowler = Convert.ToInt32(Console.ReadLine()); } } else if (Stricker == 0) { //Batsman2 = Batsman2 + 0; Team_Second_BattingLine[Battman_2_Code] = Team_Second_BattingLine[Battman_2_Code] + 0; /*Batsman2 Transfering the strike to Batsman1 after OVER completion*/ if (BallBowl % 6 == 0) { Stricker = 1; //Show the Bowler list for next over selection MatchAction.ShowBowlers(tdarr[TeamBowling_Code], TeamBowling_Code, AllTeamsPlayer); Current_Bowler = Convert.ToInt32(Console.ReadLine()); } } Display.ShowScore(TeamBatting_Code, BallBowl, Score2, wicketFallsTeam2); } else if (Action_Input == 1) { Score2 = Score2 + 1; //Adding 0 in Total Score TotalBalls_SecondInnings = --TotalBalls_SecondInnings; //Decrease 1 ball from total balls BallBowl = BallBowl + 1; if (Stricker == 1) { //Batsman1 = Batsman1 + 1; Team_Second_BattingLine[Battman_1_Code] = Team_Second_BattingLine[Battman_1_Code] + 1; Stricker = 0; /*Batsman1 Transfering the strike to Batsman2 after OVER completion*/ if (BallBowl % 6 == 0) { Stricker = 1; //Show the Bowler list for next over selection MatchAction.ShowBowlers(tdarr[TeamBowling_Code], TeamBowling_Code, AllTeamsPlayer); Current_Bowler = Convert.ToInt32(Console.ReadLine()); } } else if (Stricker == 0) { //Batsman2 = Batsman2 + 1; Team_Second_BattingLine[Battman_2_Code] = Team_Second_BattingLine[Battman_2_Code] + 1; Stricker = 1; /*Batsman2 Transfering the strike to Batsman1 after OVER completion*/ if (BallBowl % 6 == 0) { Stricker = 0; //Show the Bowler list for next over selection MatchAction.ShowBowlers(tdarr[TeamBowling_Code], TeamBowling_Code, AllTeamsPlayer); Current_Bowler = Convert.ToInt32(Console.ReadLine()); } } Display.ShowScore(TeamBatting_Code, BallBowl, Score2, wicketFallsTeam2); } else if (Action_Input == 2) { Score2 = Score2 + 2; //Adding 0 in Total Score TotalBalls_SecondInnings = --TotalBalls_SecondInnings; //Decrease 1 ball from total balls BallBowl = BallBowl + 1; if (Stricker == 1) { //Batsman1 = Batsman1 + 2; Team_Second_BattingLine[Battman_1_Code] = Team_Second_BattingLine[Battman_1_Code] + 2; /*Batsman1 Transfering the strike to Batsman2 after OVER completion*/ if (BallBowl % 6 == 0) { Stricker = 0; //Show the Bowler list for next over selection MatchAction.ShowBowlers(tdarr[TeamBowling_Code], TeamBowling_Code, AllTeamsPlayer); Current_Bowler = Convert.ToInt32(Console.ReadLine()); } } else if (Stricker == 0) { //Batsman2 = Batsman2 + 2; Team_Second_BattingLine[Battman_2_Code] = Team_Second_BattingLine[Battman_2_Code] + 2; /*Batsman2 Transfering the strike to Batsman1 after OVER completion*/ if (BallBowl % 6 == 0) { Stricker = 1; //Show the Bowler list for next over selection MatchAction.ShowBowlers(tdarr[TeamBowling_Code], TeamBowling_Code, AllTeamsPlayer); Current_Bowler = Convert.ToInt32(Console.ReadLine()); } } Display.ShowScore(TeamBatting_Code, BallBowl, Score2, wicketFallsTeam2); } else if (Action_Input == 3) { //Adding 0 in Total Score Score2 = Score2 + 3; //Decrease 1 ball from total balls TotalBalls_SecondInnings = --TotalBalls_SecondInnings; BallBowl = BallBowl + 1; if (Stricker == 1) { //Batsman1 = Batsman1 + 3; Team_Second_BattingLine[Battman_1_Code] = Team_Second_BattingLine[Battman_1_Code] + 3; Stricker = 0; /*Batsman1 Transfering the strike to Batsman2 after OVER completion*/ if (BallBowl % 6 == 0) { Stricker = 1; //Show the Bowler list for next over selection MatchAction.ShowBowlers(tdarr[TeamBowling_Code], TeamBowling_Code, AllTeamsPlayer); Current_Bowler = Convert.ToInt32(Console.ReadLine()); } } else if (Stricker == 0) { //Batsman2 = Batsman2 + 3; Team_Second_BattingLine[Battman_2_Code] = Team_Second_BattingLine[Battman_2_Code] + 3; Stricker = 1; /*Batsman2 Transfering the strike to Batsman1 after OVER completion*/ if (BallBowl % 6 == 0) { Stricker = 0; //Show the Bowler list for next over selection MatchAction.ShowBowlers(tdarr[TeamBowling_Code], TeamBowling_Code, AllTeamsPlayer); Current_Bowler = Convert.ToInt32(Console.ReadLine()); } } Display.ShowScore(TeamBatting_Code, BallBowl, Score2, wicketFallsTeam2); } else if (Action_Input == 4) { //Adding 0 in Total Score Score2 = Score2 + 4; //Counting Boundary - 4 Boundary_Batting2[0] = Boundary_Batting2[0] + 1; //Decrease 1 ball from total balls TotalBalls_SecondInnings = --TotalBalls_SecondInnings; BallBowl = BallBowl + 1; if (Stricker == 1) { //Batsman1 = Batsman1 + 4; Team_Second_BattingLine[Battman_1_Code] = Team_Second_BattingLine[Battman_1_Code] + 4; /*Batsman1 Transfering the strike to Batsman2 after OVER completion*/ if (BallBowl % 6 == 0) { Stricker = 0; //Show the Bowler list for next over selection MatchAction.ShowBowlers(tdarr[TeamBowling_Code], TeamBowling_Code, AllTeamsPlayer); Current_Bowler = Convert.ToInt32(Console.ReadLine()); } } else if (Stricker == 0) { //Batsman2 = Batsman2 + 4; Team_Second_BattingLine[Battman_2_Code] = Team_Second_BattingLine[Battman_2_Code] + 4; /*Batsman2 Transfering the strike to Batsman1 after OVER completion*/ if (BallBowl % 6 == 0) { Stricker = 1; //Show the Bowler list for next over selection MatchAction.ShowBowlers(tdarr[TeamBowling_Code], TeamBowling_Code, AllTeamsPlayer); Current_Bowler = Convert.ToInt32(Console.ReadLine()); } } Display.ShowScore(TeamBatting_Code, BallBowl, Score2, wicketFallsTeam2); } else if (Action_Input == 5) { //Adding 0 in Total Score Score2 = Score2 + 5; //Decrease 1 ball from total balls TotalBalls_SecondInnings = --TotalBalls_SecondInnings; BallBowl = BallBowl + 1; if (Stricker == 1) { //Batsman1 = Batsman1 + 5; Team_Second_BattingLine[Battman_1_Code] = Team_Second_BattingLine[Battman_1_Code] + 5; Stricker = 0; /*Batsman1 Transfering the strike to Batsman2 after OVER completion*/ if (BallBowl % 6 == 0) { Stricker = 1; //Show the Bowler list for next over selection MatchAction.ShowBowlers(tdarr[TeamBowling_Code], TeamBowling_Code, AllTeamsPlayer); Current_Bowler = Convert.ToInt32(Console.ReadLine()); } } else if (Stricker == 0) { //Batsman2 = Batsman2 + 5; Team_Second_BattingLine[Battman_2_Code] = Team_Second_BattingLine[Battman_2_Code] + 5; Stricker = 1; /*Batsman2 Transfering the strike to Batsman1 after OVER completion*/ if (BallBowl % 6 == 0) { Stricker = 0; //Show the Bowler list for next over selection MatchAction.ShowBowlers(tdarr[TeamBowling_Code], TeamBowling_Code, AllTeamsPlayer); Current_Bowler = Convert.ToInt32(Console.ReadLine()); } } Display.ShowScore(TeamBatting_Code, BallBowl, Score2, wicketFallsTeam2); } else if (Action_Input == 6) { //Adding 0 in Total Score Score2 = Score2 + 6; //Counting Boundary - 6 Runs Boundary_Batting2[1] = Boundary_Batting2[1] + 1; //Decrease 1 ball from total balls TotalBalls_SecondInnings = --TotalBalls_SecondInnings; BallBowl = BallBowl + 1; if (Stricker == 1) { //Batsman1 = Batsman1 + 6; Team_Second_BattingLine[Battman_1_Code] = Team_Second_BattingLine[Battman_1_Code] + 6; /*Batsman1 Transfering the strike to Batsman2 after OVER completion*/ if (BallBowl % 6 == 0) { Stricker = 0; //Show the Bowler list for next over selection MatchAction.ShowBowlers(tdarr[TeamBowling_Code], TeamBowling_Code, AllTeamsPlayer); Current_Bowler = Convert.ToInt32(Console.ReadLine()); } } else if (Stricker == 0) { //Batsman2 = Batsman2 + 6; Team_Second_BattingLine[Battman_2_Code] = Team_Second_BattingLine[Battman_2_Code] + 6; /*Batsman2 Transfering the strike to Batsman1 after OVER completion*/ if (BallBowl % 6 == 0) { Stricker = 1; //Show the Bowler list for next over selection MatchAction.ShowBowlers(tdarr[TeamBowling_Code], TeamBowling_Code, AllTeamsPlayer); Current_Bowler = Convert.ToInt32(Console.ReadLine()); } } Display.ShowScore(TeamBatting_Code, BallBowl, Score2, wicketFallsTeam2); } else if (Action_Input == 7) //Batsman Out Conditions { //Adding 0 in Total Score Score2 = Score2 + 0; //Decrease 1 ball from total balls TotalBalls_SecondInnings = --TotalBalls_SecondInnings; BallBowl = BallBowl + 1; //Counting OUT/Wickets in Bowler array Team2_BowlingLine[Current_Bowler] = Team2_BowlingLine[Current_Bowler] + 1; if (Stricker == 1) { //Batsman1 = Batsman1 + 3; ++BatsmanMaxCode; ++wicketFallsTeam2; Battman_1_Code = BatsmanMaxCode; Stricker = 1; /*Batsman1 Transfering the strike to Batsman2 after OVER completion*/ if (BallBowl % 6 == 0) { Stricker = 0; //Show the Bowler list for next over selection MatchAction.ShowBowlers(tdarr[TeamBowling_Code], TeamBowling_Code, AllTeamsPlayer); Current_Bowler = Convert.ToInt32(Console.ReadLine()); } } else if (Stricker == 0) { //Batsman2 = Batsman2 + 3; ++BatsmanMaxCode; ++wicketFallsTeam2; Battman_2_Code = BatsmanMaxCode; Stricker = 0; /*Batsman2 Transfering the strike to Batsman1 after OVER completion*/ if (BallBowl % 6 == 0) { Stricker = 1; //Show the Bowler list for next over selection MatchAction.ShowBowlers(tdarr[TeamBowling_Code], TeamBowling_Code, AllTeamsPlayer); Current_Bowler = Convert.ToInt32(Console.ReadLine()); } } Display.ShowScore(TeamBatting_Code, BallBowl, Score2, wicketFallsTeam2); } else if (Action_Input == 8) { //Adding 1 in Total Score (WHITE BALL) Score2 = Score2 + 1; WhiteBowled_Team2 = WhiteBowled_Team2 + 1; } } //int[] BatsmansCode, int[] BowlerCode, int Score1, int[] Boundary_Batting, string[,] AllTimePlayers, int TeamBattingCode, int TeamBowlingCode } Display.ShowScoreCard(Team_Second_BattingLine, Team2_BowlingLine, Score2, Boundary_Batting2, AllTeamsPlayer, TeamBatting_Code, TeamBowling_Code); Display.ShowMatchResult(Score1, Score2, Team1_Name, Team2_Name, wicketFallsTeam1, wicketFallsTeam2); }