public void PurchaseStock(Stock stock, int amount) { if (_verifier(stock)) { BuyOrSell buyOrSell = new BuyOrSell(stock, amount, BuyOrSell.BuyOrSellEnum.Buy); } }
public double Value(List <Stock> stockList) { List <Tuple <string, int> > HeldStockList = new List <Tuple <string, int> >(); foreach (Transaction curTrans in _transactionList) { if (curTrans.GetType() == typeof(BuyOrSell)) { BuyOrSell curBOS = (BuyOrSell)curTrans; Tuple <string, int> createdTuple = null; Tuple <string, int> foundTuple = null; foreach (Tuple <string, int> heldTuple in HeldStockList) { if (curBOS.StockName == heldTuple.Item1) { if (curBOS.BuyOrSellState == BuyOrSell.BuyOrSellEnum.Buy) { createdTuple = Tuple.Create(heldTuple.Item1, heldTuple.Item2 + curBOS.Quantity); } else { createdTuple = Tuple.Create(heldTuple.Item1, heldTuple.Item2 - curBOS.Quantity); } break; } } if (createdTuple != null) { HeldStockList[HeldStockList.IndexOf(foundTuple)] = createdTuple; } else { HeldStockList.Add(createdTuple); } } } double sum = 0; foreach (Tuple <string, int> heldStock in HeldStockList) { double heldStockPrice; foreach (Stock stock in stockList) { if (heldStock.Item1 == stock.Name) { sum += heldStock.Item2 * stock.Price; } } } return(sum); }