Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            MessageSubscriberOne   s1 = new MessageSubscriberOne();
            MessageSubscriberTwo   s2 = new MessageSubscriberTwo();
            MessageSubscriberThree s3 = new MessageSubscriberThree();
            Subject subject           = new Subject();

            subject.attach(s1);
            subject.attach(s2);
            subject.State = 2;
            subject.attach(s3);
            Console.WriteLine();
            subject.detach(s2);
            subject.State = 3;
            Console.ReadLine();
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            MessageSubscriber sub1 = new MessageSubscriber();

            MessageSubscriberTwo sub2 = new MessageSubscriberTwo();

            MessageSubscriberThree sub3 = new MessageSubscriberThree();

            MessagePublisher pub = new MessagePublisher();


            pub.Attach(sub1);
            pub.Attach(sub2);
            pub.Attach(sub3);

            pub.ChangeState(2);

            Console.ReadLine();
        }