public static void BuyProduct(int keyPush, int latestKeyPush) { if (ProductStock.CheckSupply(keyPush)) { Vending.DetailTheExchange(keyPush, latestKeyPush); } else { ConcatenateCurrentMessage($"We have run out of {ProductStock.ShowProductInfo(keyPush).ProductName}"); } }
public static void ConcatenateCurrentMessage(string message) { Product product = ProductStock.ShowProductInfo(Keypad.newKeyPush); if (message.Contains("to confirm") || message.Contains("miss by")) { Display.ChangeCurrentMessage(product.ProductName + " for " + product.ProductPrice + ". " + message); } else if (message.Contains("run out") || message.Contains("not recognized") || message.Contains("Enjoy")) { Display.ChangeCurrentMessage(message); } }
public static void DetailTheExchange(int keyPush, int preceedingKeyPush) { if (debtToCustomer > ProductStock.ShowProductInfo(keyPush).ProductPrice) { if (keyPush == preceedingKeyPush && Display.RevealCurrentMessage().Contains("to confirm")) { ProductStock.SendProduct(keyPush); debtToCustomer -= ProductStock.ShowProductInfo(keyPush).ProductPrice; } else { ActivityControl.ConcatenateCurrentMessage($"Push {keyPush} to confirm buy"); } } else { ActivityControl.ConcatenateCurrentMessage($"You miss by {debtToCustomer - ProductStock.ShowProductInfo(keyPush - 1).ProductPrice}kr"); } }