Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApplication2 {
- public class BallGame {
- public event EventHandler<BallHitEventArgs> BallHit;
- public event EventHandler GameOver;
- public void HitBall(int mph, int compassDirection) {
- Console.WriteLine("[PUBLISHER:] I have just the ball [{0} mph] [compass direction:{1}]", mph, compassDirection);
- OnBallHit(mph, compassDirection);
- Console.WriteLine("[PUBLISHER:] I am telling you this game is over");
- OnGameOver();
- }
- private void OnBallHit(int mph, int compassDirection) {
- if (BallHit != null) {
- BallHit(this, new BallHitEventArgs(mph, compassDirection));
- }
- }
- private void OnGameOver() {
- if (GameOver != null) {
- GameOver(this, EventArgs.Empty);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement