public void addStock(Stock stock, int number) { StockWithCount stockWithCount = new StockWithCount(stock, 0); for (int i = 0; i < stocks.Count; i++) { if (stocks[i].stock.checkName(stock.name)) { stockWithCount = stocks[i]; stocks.RemoveAt(i); break; } } stockWithCount.count += number; stocks.Add(stockWithCount); }
public int numberOfShares(string name) { StockWithCount stock = getStock(name); return(stock.count); }