private static void AddBalance(IVendingMachine machine) { bool response = true; while (response) { Console.WriteLine("Enter amount to top up Wallet: "); string amount = Console.ReadLine(); decimal topUp; if (decimal.TryParse(amount, out topUp)) { try { machine.TopUpWallet(topUp); response = false; } catch (NegativeAdditionException) { response = true; Console.WriteLine("Wrong Input! Please try again"); } } else { Console.WriteLine("Wrong Input! Please try again"); } } GetInput(machine); }
private static void InitialTopUpWallet(IVendingMachine machine, decimal amount) { machine.TopUpWallet(amount); }