public virtual bool Validate(IBanknote banknote) { if (banknote.Currency == Currency && banknote.Value == Value) { return(true); } return(_nextHandler != null && _nextHandler.Validate(banknote)); }
public virtual bool Validate(ref string money, out string banknotes) { var amount = int.Parse(money); var banknoteCount = amount / Value; money = (amount % Value).ToString(); var cache = banknoteCount == 0 ? "" : $"{Value}x{banknoteCount}"; if (_nextHandler != null && money != "0") { if (!_nextHandler.Validate(ref money, out banknotes)) { return(false); } cache = cache == "" ? banknotes : cache + " + " + banknotes; } banknotes = cache; return(money == "0"); }
public bool Validate(int value, Currency currency) => handler.Validate(value, currency);
public bool Validate(string banknote) { return(_handler.Validate(banknote)); }
public bool Validate(IBanknote banknote) { return(_handler.Validate(banknote)); }
public bool Validate(Banknote banknote) => _handler.Validate(banknote);