private static void RunChangeCalculator() { _changeCalculator = new Infrastructure.Instances.ChangeCalculator(); while (true) { var itemCostResult = GetInputValue("item cost"); if (itemCostResult.exit) { return; } var amountGivenResult = GetInputValue("amount given"); if (amountGivenResult.exit) { return; } var change = _changeCalculator.CalculateChange (amountGivenResult.value, itemCostResult.value); if (change < 0) { continue; } _changeCalculator.GiveChange(change); break; } }
public IActionResult Index(int?pay, int?amount) { if (pay.HasValue && amount.HasValue) { var result = changeCalculator.CalculateChange(pay.Value, amount.Value); ViewData["pay"] = pay.Value; ViewData["amount"] = amount.Value; return(View(result)); } else { return(View()); } }
private PurchaseResult ProcessPurchase(double[] coinsEntered) { if (SelectedProduct != null) { var change = _changeCalculator.CalculateChange( new Transaction { Product = SelectedProduct, CoinsEntered = coinsEntered }); var result = new PurchaseResult { Accepted = change >= 0, AmountDue = change }; return(result); } return(null); }
public ChangeModel Calculate(int pay, int amount) { var result = changeCalculator.CalculateChange(pay, amount); return(result); }