public void Sell(BoardSecurity sellingSecurity) { // TODO: check if we have this security at all var sellQuantity = OwnedSecurities.First(x => x.Security == sellingSecurity.Security).Quantity; Sell(sellingSecurity, sellQuantity); }
public int MaxBuy(BoardSecurity purchaseSecurity) { int affordableShares = ((Balance / (purchaseSecurity.CostPerShare) / 10) * 10); // TODO: technically this should be only in groups of 10 Buy(purchaseSecurity, affordableShares); return(affordableShares); }
public void Sell(BoardSecurity sellingSecurity, int sellQuantity) { // TODO: check if we have this security at all if (OwnedSecurities.First(x => x.Security == sellingSecurity.Security).Quantity < sellQuantity) { // Not enough of this sellingSecurities to do this transaction return; } // TODO: adjust sellQuantity available in gameplay OwnedSecurities.First(x => x.Security == sellingSecurity.Security).Quantity -= sellQuantity; Balance += sellingSecurity.CostPerShare * sellQuantity; if (sellQuantity > 0) { System.Console.WriteLine($"{Name} sold {sellQuantity} shares of {sellingSecurity.Security.Name} for {sellingSecurity.CostPerShare * sellQuantity}"); } }
public void Buy(BoardSecurity purchaseSecurity, int purchaseQuantity) { var cost = purchaseSecurity.CostPerShare * purchaseQuantity; if (cost > Balance) { // Not enough $ to do this transaction return; } // TODO: adjust sellQuantity available in gameplay if (OwnedSecurities.First(s => s.Security == purchaseSecurity.Security) == null) { OwnedSecurities.Add(new PurchasedSecurity(purchaseSecurity.Security)); } OwnedSecurities.First(s => s.Security == purchaseSecurity.Security).Quantity += purchaseQuantity; Balance -= cost; if (purchaseQuantity > 0) { System.Console.WriteLine($"{Name} purchased {purchaseQuantity} shares of {purchaseSecurity.Security.Name} for {cost}"); } }