public Banknote[] GetCash(CurrencyType currency, int amountOfMoney) { var currentResult = _nextHandler?.GetCash(currency, amountOfMoney); if (currency != Banknote.Currency) { return(currentResult); } var sum = currentResult.Sum(); if (sum == amountOfMoney) { return(currentResult); } var residue = amountOfMoney - sum; var outAmountOfBanknote = Math.Min(residue / Banknote.Value, AmountOfBanknote); var result = new List <Banknote>(currentResult ?? new Banknote[0]); for (var i = 0; i < outAmountOfBanknote; i++) { result.Add(Banknote); } return(result.ToArray()); }