コード例 #1
0
        private ExchangeDetails?ExchangeStock(Stock stock, IStockOwner newOwner)
        {
            newOwner.AddStock(stock);

            stock.Owner.UpdateHoldings();
            return(null);
        }
コード例 #2
0
 public Stock(Stock s, double percentage)
 {
     Percentage    = percentage;
     s.Percentage -= percentage;
     company       = s.company;
     Owner         = s.Owner;
     //create new stock from other stock
 }
コード例 #3
0
        public bool BuyStock(Stock stock, IStockOwner buyer)
        {
            if (stock == null)
            {
                return(false);
            }
            if (StocksForSale[Companies.IndexOf(stock.company)].Contains(stock))
            {
                buyer.money       -= stock.SellPrice;
                stock.Owner.money += stock.SellPrice;

                /*ExchangeDetails? ed = */ ExchangeStock(stock, buyer);
                return(true);
            }
            return(false);
        }