Esempio n. 1
0
        static void Main(string[] args)
        {
            AbstractObserver Beijing = ConcreteCityObserver.newInstance("Beijing", 8);
            AbstractObserver London  = ConcreteCityObserver.newInstance("London", 0);
            AbstractObserver Moscow  = ConcreteCityObserver.newInstance("Moscow", 4);
            AbstractObserver Sydney  = ConcreteCityObserver.newInstance("Sydney", 10);
            AbstractObserver NewYork = ConcreteCityObserver.newInstance("NewYork", -5);

            ConcreteClockSubject clock = ConcreteClockSubject.newInstance();

            clock.attach(Beijing);
            clock.attach(London);
            clock.attach(Moscow);
            clock.attach(Sydney);
            clock.attach(NewYork);

            clock.setUtcTime(DateTime.Parse("2013-9-2 0:00:00"));
            Console.WriteLine();

            Beijing.adjustTime(clock, DateTime.Parse("2013-9-2 9:00:00"));
            Console.WriteLine();

            London.adjustTime(clock, DateTime.Parse("2013-10-28 0:00:00"));

            Console.ReadKey();
        }
Esempio n. 2
0
        public void Init()
        {
            Beijing = ConcreteCityObserver.newInstance("Beijing", 8);
            London  = ConcreteCityObserver.newInstance("London", 0);
            Moscow  = ConcreteCityObserver.newInstance("Moscow", 4);
            Sydney  = ConcreteCityObserver.newInstance("Sydney", 10);
            NewYork = ConcreteCityObserver.newInstance("NewYork", -5);

            clock = ConcreteClockSubject.newInstance();

            attachObervers();
            clock.setUtcTime(DateTime.Parse("2013-9-2 0:00:00"));
        }