static void Main(string[] args) { Person x = new Person(); Employee e = new Employee(); e.FirstName = "Magesh"; e.LastName = "Kuppan"; e.DOB = new DateTime(1997, 3, 10); e.Salary = 20000; Console.WriteLine("As an Employee"); e.Display(); Person p = e; Console.WriteLine("As a Person"); p.Display(); var cricketPlayer1 = new CricketPlayer { FirstName = "Sachin", LastName = "Tendulkar" }; cricketPlayer1.Play(); Console.ReadKey(); }
public BowlingTeamPlayer(CricketPlayer player) : base(player) { if (player != null) { this.Id = player.Id; this.Name = player.Name; this.PlayerRole = player.PlayerRole; this.IsSerializePlayerRoler = false; } }
public void SetBatsmenComingOn(CricketPlayer selectdPlayer) { var newBatsmen = new BattingTeamPlayer(selectdPlayer); this.CurrentInnings().BattingTeamPlayers.Add(newBatsmen); if (this.CurrentInnings().Striker == null) { this.CurrentInnings().Striker = newBatsmen; } else { this.CurrentInnings().NonStriker = newBatsmen; } }
public void SetStrikerNonStrikerBatsmen(CricketPlayer selectdPlayer, bool isStriker) { var newBatsmen = new BattingTeamPlayer(selectdPlayer); this.CurrentInnings().BattingTeamPlayers.Add(newBatsmen); if (isStriker) { this.CurrentInnings().Striker = newBatsmen; } else { this.CurrentInnings().NonStriker = newBatsmen; } }
public void StartOver(CricketPlayer bowler) { var newBowler = new BowlingTeamPlayer(bowler); CurrentInnings().BowlingTeamPlayers.Add(newBowler); var over = new Over { OverStauts = OverStatus.OverInProgress, //Bowler = player, Number = this.CurrentInnings().Overs.Count + 1, BowlerId = bowler.Id }; CurrentInnings().Overs.Add(over); }
static void Main(string[] args) { // CricketPlayer c = new CricketPlayer(); // HockeyPlayer h = new HockeyPlayer(); Console.WriteLine("Menu \n 1.Cricket PLayer DEtails\n 2.Hockey Details "\n "enter Choice"); int ch = int.Parse(Console.ReadLine()); if (ch == 1) { Console.WriteLine("Enter Name:"); string Name = Console.ReadLine(); Console.WriteLine("Enter TeamName:"); string TeamName = Console.ReadLine(); Console.WriteLine("No.of Matches Played"); int NoofMatches = int.Parse(Console.ReadLine()); Console.WriteLine("Noof TotalRunsScored"); int TotalRunsScored = int.Parse(Console.ReadLine()); Console.WriteLine("Noof WicketsTaken"); int WicketsTaken = int.Parse(Console.ReadLine()); CricketPlayer c = new CricketPlayer(Name,TeamName,NoofMatches,TotalRunsScored,WicketsTaken); c.DisplayPlayerStatistics(); } else if(ch==2) { Console.WriteLine("Enter Name:"); string Name = Console.ReadLine(); Console.WriteLine("Enter TeamName:"); string TeamName = Console.ReadLine(); Console.WriteLine("No.of Matches Played"); int NoofMatches = int.Parse(Console.ReadLine()); Console.WriteLine("Position"); int Position = int.Parse(Console.ReadLine()); Console.WriteLine("NoofGoals"); int NoofGoals = int.Parse(Console.ReadLine()); HockeyPlayer c = new CricketPlayer(Name, TeamName, NoofMatches, Position,NoofGoals); h.DisplayPlayerStatistics(); Console.WriteLine(); } }
public void AddBall(BallType ballType, RunsType runsType, BoundaryType boundaryType, int runs, CricketPlayer playerBowler, CricketPlayer playreBtsmen, bool isDismissal, CricketPlayer dismissedPlayer, CricketPlayer playerFielder, DisMissalType disMissalType) { var batsmen = this.CurrentInnings().BattingTeamPlayers.FirstOrDefault(x => x.Id == playreBtsmen.Id); var bowler = this.CurrentInnings().BowlingTeamPlayers.FirstOrDefault(x => x.Id == playerBowler.Id); var innings = this.CurrentInnings(); var over = this.CurrentOver(); var ball = new Ball { BallAttemptStatus = BallAttemptStatus.InProgress, BallType = ballType, RunsType = runsType, BoundaryType = boundaryType, Runs = runs, IsDismissal = isDismissal, DisMissalType = disMissalType, }; if (batsmen != null) { ball.BatsmenId = batsmen.Id; } if (bowler != null) { ball.BowlerId = bowler.Id; bowler.BallsBowled++; } if (playerFielder != null) { ball.FielderId = playerFielder.Id; } switch (ball.BallType) { case BallType.Legitimate: ball.BallNumber = CurrentOver().Balls.Count(x => x.IsFinished) + 1; ball.BallAttemptNumber = 1; ball.IsFinished = true; innings.Runs += runs; over.Runs += runs; batsmen.BallsFaced++; batsmen.Runs += runs; bowler.RunsConceded += runs; if (ball.Runs == 0) { batsmen.NumberOfDotBalls++; bowler.NumberOfDotBallsBowled++; innings.NumberOfDotBalls++; } break; case BallType.Wide: ball.Extras = this.WideValue + runs; ball.BallAttemptNumber = ball.BallAttemptNumber + 1; ball.BallNumber = CurrentOver().Balls.Count(x => x.IsFinished); innings.Wides += 1; innings.WideRuns += this.WideValue + runs; over.Extras += this.WideValue + runs; bowler.NumberOfWidesBowled++; bowler.RunsConceded += this.WideValue + runs; break; case BallType.NoBall: if (ball.RunsType == RunsType.Run) { ball.Extras = this.NoBallValue; ball.Runs = runs; innings.NoBallRuns += this.NoBallValue; innings.Runs += runs; batsmen.Runs += runs; } else { ball.Extras = this.NoBallValue + runs; innings.NoBallRuns += this.NoBallValue + runs; } ball.BallAttemptNumber = ball.BallAttemptNumber + 1; ball.BallNumber = CurrentOver().Balls.Count(x => x.IsFinished); innings.NoBalls += 1; over.Extras += this.NoBallValue + runs; batsmen.BallsFaced++; bowler.NumberOfNoBallsBowled++; bowler.RunsConceded += this.NoBallValue + runs; break; } switch (ball.RunsType) { case RunsType.Byes: ball.Extras = runs; ball.Runs = 0; innings.Byes += runs; over.Extras = runs; break; case RunsType.LegByes: ball.Extras = runs; ball.Runs = 0; innings.Legbyes += runs; over.Extras = runs; bowler.RunsConceded += runs; break; } switch (ball.BoundaryType) { case BoundaryType.Four: innings.NumberOfFours++; batsmen.NumberOfFours++; bowler.NumberOfFoursConceded++; break; case BoundaryType.Six: innings.NumberOfSixers++; batsmen.NumberOfSixers++; bowler.NumberOfSixersConceded++; break; } if (isDismissal) { switch (disMissalType) { case DisMissalType.Bowled: case DisMissalType.Caught: case DisMissalType.StumpOut: case DisMissalType.HitWicket: case DisMissalType.Lbw: bowler.NumberOfWickets++; break; } if (dismissedPlayer != null) { batsmen.Dismissed = true; } } innings.NumberOfOversBowled = over.Number - 1 + "." + ball.BallNumber; CurrentOver().Balls.Add(ball); var striker = this.CurrentInnings().Striker; var nonStriker = this.CurrentInnings().NonStriker; if (IsOdd(ball.Runs)) { this.CurrentInnings().Striker = nonStriker; this.CurrentInnings().NonStriker = striker; } if (isDismissal) { if (dismissedPlayer != null && dismissedPlayer.Id == striker.Id) { CurrentInnings().Striker = null; } else { CurrentInnings().NonStriker = null; } } var timelineAction = new TimelineAction { InningsNumber = innings.InningsNumber, OverNumber = over.Number, BallNumber = ball.BallNumber, BallAttemptNumber = ball.BallAttemptNumber, BallType = ball.BallType, RunsType = ball.RunsType, Runs = ball.Runs }; if (batsmen != null) { timelineAction.BatsmenId = batsmen.Id; } if (bowler != null) { timelineAction.BowlerId = bowler.Id; bowler.BallsBowled++; } if (playerFielder != null) { timelineAction.FielderId = playerFielder.Id; } this.CurrentInnings().TimelineActions.Add(timelineAction); }