Esempio n. 1
0
        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;
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
 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;
 }