A client of die that reports 'two sixes in a row' via an event. | Lecture 5 - slide 40 : 45 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); } } } |