Advertisement
Dennisaa

Program.cs - BallGame

Sep 19th, 2015
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.90 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApplication2 {
  4.     class Program {
  5.         static void Main(string[] args) {
  6.            
  7.             var bat = new BallGame();
  8.  
  9.             // Start listening for the ball being hit...
  10.             bat.BallHit += new EventHandler<BallHitEventArgs>(bat_BallHit);
  11.             // ... and listen for the game being over...
  12.             bat.GameOver += new EventHandler(bat_GameOver);
  13.  
  14.             // start the game...
  15.             bat.HitBall(20, 359);
  16.             Console.Read();
  17.         }
  18.  
  19.         private static void bat_GameOver(object sender, EventArgs e) {
  20.             Console.WriteLine("[SUBSCRIBER:] I have just been told that the game is over");
  21.         }
  22.  
  23.         private static void bat_BallHit(object sender, BallHitEventArgs e) {
  24.             Console.WriteLine("[SUBSCRIBER:] I have just been told that the ball was hit:" + e.Mph);
  25.         }
  26.     }
  27.  
  28.  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement