Back to notes -- Keyboard shortcut: 'u'  previous -- Keyboard shortcut: 'p'  next -- Keyboard shortcut: 'n'  Slide program -- Keyboard shortcut: 't'    A client of die that reports 'two sixes in a row' via an event.Lecture 6 - slide 14 : 20
Program 2
using System;

class diceApp {   

  public static void Main(){

    Die d1 = new Die();   

    d1.twoSixesInARow +=               
     delegate (string mes){            
       Console.WriteLine(mes);
     };

    for(int i = 1; i < 100; i++){      
      d1.Toss();
      Console.WriteLine("{0}: {1}", i, d1.NumberOfEyes);  
    }

 }
}
 
 
A client of a Die.
 
 
 
We make a Die.
 
We add an anonymous method
to the public event in Die d1.
 
 
 
Tossing the Die d1 hundred times.