/// <summary>
        /// The test forth.
        /// </summary>
        private static void TestForth()
        {
            // Create IBM stock and attach investors
            IbmStock ibmStock = new IbmStock("IBM", 120.00);

            ibmStock.Attach(new Investor("Sorrows"));
            ibmStock.Attach(new Investor("Berkshire"));

            // Fluctuating prices will notify investors
            ibmStock.Price = 120.10;
            ibmStock.Price = 121.00;
            ibmStock.Price = 120.50;
            ibmStock.Price = 120.75;

            // Wait for user
            Console.ReadKey();
        }
Esempio n. 2
0
        private static void ClearImplementationExample()
        {
            // Create stocks and attach investors
            var sorrosInvestor    = new SorrosInvestor();
            var berkshireInvestor = new BerkshireInvestor();

            var ibmStock = new IbmStock(120.00);

            ibmStock.Attach(sorrosInvestor);
            ibmStock.Attach(berkshireInvestor);

            var googleStock = new GoogleStock(200.00);

            googleStock.Attach(sorrosInvestor);
            googleStock.Attach(berkshireInvestor);

            // Fluctuating prices will notify investors
            ibmStock.Price = 120.10;
            ibmStock.Price = 121.00;
            ibmStock.Detach(sorrosInvestor);
            ibmStock.Price    = 120.50;
            ibmStock.Price    = 120.75;
            googleStock.Price = 202.00;
        }