コード例 #1
0
        /// <summary>
        /// The attach.
        /// </summary>
        /// <param name="investor">
        /// The investor.
        /// </param>
        public override void Attach(Investor investor)
        {
            List <IInvestor> aList = this.Investors;

            aList.Add(investor);
            this.Investors = aList;
        }
コード例 #2
0
        static void Main(string[] args)
        {
            NasdaqStock stock = new NasdaqStock("Microsoft", 100);

            Investor investor1 = new Investor("Adam");
            Investor investor2 = new Investor("John");

            stock.Attach(investor1);
            stock.Attach(investor2);

            stock.Price = 101;
            stock.Price = 110;

            Console.ReadKey();
        }
コード例 #3
0
        static void Main(string[] args)
        {
            Investor gzy = new Investor("龚儿子");
            Investor mzw = new Investor("马孙子");

            Snack whh = new Snack("哇哈哈", 2.0);

            whh.Attach(gzy);
            whh.Attach(mzw);

            whh.Price = 2.5;
            whh.Price = 2.0;
            whh.Price = 1.5;

            Console.ReadKey();
        }
コード例 #4
0
        static void Main(string[] args)
        {
            var company = new Company("Toch Industries");

            var investorRoka   = new Investor("Roka");
            var investorJohn   = new Investor("John");
            var investorRuslan = new Investor("Ruslan");
            var investorBodya  = new Investor("Bodya");

            company.Attach(investorRoka);
            company.Attach(investorRuslan);
            company.Attach(investorBodya);
            company.Cash = 33.45;
            Console.WriteLine();

            company.Detach(investorRoka);
            company.Attach(investorJohn);
            company.Cash = 20.5;
            Console.WriteLine();
            company.Cash = 33;
        }
コード例 #5
0
        internal static void Main()
        {
            // Create IBM stock and attach investors
            var ibm = new IBM("IBM", 120.00);

            var sorros = new Investor("Sorros");

            ibm.Attach(sorros);
            ibm.Attach(new Investor("Berkshire"));

            // Fluctuating prices will notify investors
            ibm.Price = 120.10;
            ibm.Price = 121.00;

            ibm.Detach(sorros);

            ibm.Price = 120.50;

            ibm.Attach(sorros);
            ibm.Price = 120.75;
        }
コード例 #6
0
        public static void Main()
        {
            var microsoftStock = new MicrosoftStock();

            microsoftStock.Symbol = "MS";

            var investor1 = new Investor();

            investor1.Name = "Bill Gates";
            var investor2 = new Investor();

            investor2.Name = "Berkshire";

            microsoftStock.Attach(investor1);
            microsoftStock.Attach(investor2);

            microsoftStock.Price = 120.10;
            microsoftStock.Price = 121.00;
            microsoftStock.Price = 120.50;
            microsoftStock.Price = 120.75;
        }
コード例 #7
0
 public void Detach(Investor investor)
 {
     investors.Remove(investor);
 }
コード例 #8
0
 public void Attach(Investor investor)
 {
     investors.Add(investor);
 }
 /// <summary>
 /// The attach.
 /// </summary>
 /// <param name="investor">
 /// The investor.
 /// </param>
 public abstract void Attach(Investor investor);