Exemple #1
0
        public void Print()
        {
            Ball          ball    = new Ball();
            Pitcher       pitcher = new Pitcher(ball);
            BallEventArgs e       = new BallEventArgs(12, 100);

            ball.OnBallInPlay(e);
        }
Exemple #2
0
            public void OnBallInPlay(BallEventArgs e)
            {
                Console.WriteLine("Ball Play");

                // BallInPlay?.Invoke(this, e);
                // c# headfirst 708
                EventHandler <BallEventArgs> ballInPlay = BallInPlay;

                if (ballInPlay != null)
                {
                    ballInPlay(this, e);
                }
            }
Exemple #3
0
 private void Ball_BallInPlay(object sender, EventArgs e)
 {
     Console.WriteLine("Pitcher");
     if (e is BallEventArgs)
     {
         BallEventArgs ballEventArgs = e as BallEventArgs;
         if (ballEventArgs.Distance < 95 && ballEventArgs.Tragectory < 60)
         {
             CatchBall();
         }
         else
         {
             CoverFirstBase();
         }
     }
 }