Пример #1
0
        static void Main(string[] args)
        {
            Subject subject = new Subject();

            BinaryObserver binaryObserver = new BinaryObserver();
            OctalObserver  octalObserver  = new OctalObserver();
            HexaObserver   hexaObserver   = new HexaObserver();

            subject.Attach(binaryObserver);
            subject.Attach(octalObserver);
            subject.Attach(hexaObserver);
            subject.SendMessage("Nofify Messages");
        }
Пример #2
0
        static void Main(string[] args)
        {
            Subject             subject             = new Subject();
            BinaryObserver      binaryObserver      = new BinaryObserver(subject);
            OctalObserver       octalObserver       = new OctalObserver(subject);
            DecimalObserver     decimalObserver     = new DecimalObserver(subject);
            HexaDecimalObserver hexaDecimalObserver = new HexaDecimalObserver(subject);

            int state = 15;

            Console.WriteLine($"First state: {state}");
            subject.State = state;
            state         = 10;
            Console.WriteLine($"Second state: {state}");
            subject.State = state;
        }