public Change MakeChange(decimal value) { var change = new Change(); foreach (var currency in _randomizer.Shuffle(new List<ICurrency>(_money.DecreasingValueCurrency))) if (value >= currency.Value) { change.Add(currency, (int)Math.Floor(value / currency.Value)); value -= currency.Value * change.NumberOf(currency); } return change; }
public virtual Change MakeChange(decimal value) { var change = new Change(); foreach(var currency in _money.DecreasingValueCurrency) { if (value >= currency.Value) { change.Add(currency, (int)Math.Floor(value / currency.Value)); value -= currency.Value * change.NumberOf(currency); } } return change; }