static void Main(string[] args) { Genrator gen = new Genrator(); IObserver firstSubscriber = new Observer(gen); firstSubscriber.update(); IObserver secondSubscriber = new Observer(gen); secondSubscriber.update(); IObserver thirdSubscriber = new Observer(gen); thirdSubscriber.update(); ConsoleKeyInfo key; key = Console.ReadKey(); while (key.Key != ConsoleKey.E) { firstSubscriber.update(); secondSubscriber.update(); thirdSubscriber.update(); } Console.ReadLine(); }
public Observer(Genrator generator) { this.generator = generator; this.generator.Attach(this); }