diff --git a/CoffeeVendingMachines/CoffeeVendingMachine.cs b/CoffeeVendingMachines/CoffeeVendingMachine.cs index 7b88ded..aeabf38 100644 --- a/CoffeeVendingMachines/CoffeeVendingMachine.cs +++ b/CoffeeVendingMachines/CoffeeVendingMachine.cs @@ -45,8 +45,27 @@ public class CoffeeVendingMachine public CoinDepot[] Cancel() { - //TODO - return []; + int count = 0; + foreach (var inputCoin in _currentInputCoins) + { + if (inputCoin.Count > 0) + { + count++; + } + } + CoinDepot[] newInputCoins = new CoinDepot[count]; + + int j = 0; + for (int i = 0; i < _currentInputCoins.Length; i++) + { + if (_currentInputCoins[i].Count > 0) + { + newInputCoins[j] = new CoinDepot(_currentInputCoins[i]); + j++; + } + } + + return newInputCoins; } ///