public virtual void BallFaced(Delivery delivery) { if (delivery == null) throw new ArgumentNullException("delivery"); if (! NotOut) throw new InvalidOperationException("Cannot face a Delivery after being dismissed!"); ballsFaced++; runsScored += delivery.RunsScored; }
public virtual void RecordDelivery(Player batter, int runsScored) { if (batter == null) throw new ArgumentNullException("batter"); if (IsOver()) throw new InvalidOperationException("Over is over so can't fit more deliveries!"); var batterInnings = BattingTeamInnings.GetBatterInnings(batter); if (! batterInnings.NotOut) throw new InvalidOperationException("Batter is out!"); var delivery = new Delivery(Bowler, batter, runsScored); deliveries.Add(delivery); batterInnings.BallFaced(delivery); }
public bool Equals(Delivery other) { if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; return Equals(other.Bowler, Bowler) && Equals(other.Batter, Batter) && other.RunsScored == RunsScored; }