Exemple #1
0
    public static void RunObserver()
    {
      IInvestor steve = new Investor(100, "Steve Jobs");
      IInvestor bill = new Investor(101, "Bill Gates");
      IInvestor james = new Investor(102, "James Gosling");

      IStock philipsStock = new Stock("Apple Inc.", 1000.0);
      philipsStock.Register(steve);
      philipsStock.Register(bill);

      IStock aluStock = new Stock("Microsoft Corp.", 500.0);
      aluStock.Register(steve);
      aluStock.Register(james);

      philipsStock.Price += 2.0;
      aluStock.Price += 3.5;

      philipsStock.Price -= 0.7;
      aluStock.Price -= 1.4;
    }
Exemple #2
0
        public static void RunObserver()
        {
            IInvestor steve = new Investor(100, "Steve Jobs");
            IInvestor bill  = new Investor(101, "Bill Gates");
            IInvestor james = new Investor(102, "James Gosling");

            IStock philipsStock = new Stock("Apple Inc.", 1000.0);

            philipsStock.Register(steve);
            philipsStock.Register(bill);

            IStock aluStock = new Stock("Microsoft Corp.", 500.0);

            aluStock.Register(steve);
            aluStock.Register(james);

            philipsStock.Price += 2.0;
            aluStock.Price     += 3.5;

            philipsStock.Price -= 0.7;
            aluStock.Price     -= 1.4;
        }