public void Print() { Ball ball = new Ball(); Pitcher pitcher = new Pitcher(ball); BallEventArgs e = new BallEventArgs(12, 100); ball.OnBallInPlay(e); }
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); } }
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(); } } }