Example #1
0
 public virtual bool Validate(IBanknote banknote)
 {
     if (banknote.Currency == Currency && banknote.Value == Value)
     {
         return(true);
     }
     return(_nextHandler != null && _nextHandler.Validate(banknote));
 }
Example #2
0
        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");
        }
Example #3
0
 public bool Validate(int value, Currency currency) => handler.Validate(value, currency);
Example #4
0
 public bool Validate(string banknote)
 {
     return(_handler.Validate(banknote));
 }
Example #5
0
 public bool Validate(IBanknote banknote)
 {
     return(_handler.Validate(banknote));
 }
 public bool Validate(Banknote banknote) => _handler.Validate(banknote);