Head First C# Code: Chapter 11
Baseball with Callback
Form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace _1_Baseball___with_callback
{
public partial class Form1 : Form
{
Ball ball = new Ball();
Pitcher pitcher;
Fan fan;
public Form1()
{
InitializeComponent();
pitcher = new Pitcher(ball);
fan = new Fan(ball);
}
private void playBall_Click(object sender, EventArgs e)
{
Bat bat = ball.GetNewBat();
BallEventArgs ballEventArgs = new BallEventArgs(
(int)trajectory.Value, (int)distance.Value);
ball.OnBallInPlay(ballEventArgs);
}
}
}







