static void Main(string[] args) { string market = Properties.Settings.Default.Market; string className = $"AbstractFactory.{market}Factory"; IFactory factory = (IFactory)Assembly.Load("AbstractFactory").CreateInstance(className); IStock stock = factory.CreateStock(); stock.Buy(); stock.Sell(); IFund fund = factory.CreateFund(); fund.Buy(); fund.Sell(); Console.Read(); }
public void buyStock(int amount, IStock stock) { if (amount < 0) { return; } int bought = stock.Buy(amount); //see if stock exsists: foreach (var VARIABLE in StockList) { if (VARIABLE.Name == stock.Name) { VARIABLE.AvailibleAmount += bought; return; } } StockList.Add(new Stock(stock.Name, stock.Price, bought)); }