Esempio n. 1
0
        public virtual (List <BankRoll> money, bool success) Withdraw(CurrencyType currencyType, int value)
        {
            if (currencyType != Banknote.Currency && _nextHandler != null)
            {
                return(_nextHandler.Withdraw(currencyType, value));
            }

            if (value % Banknote.Value == 0)
            {
                return(new List <BankRoll>()
                {
                    new BankRoll()
                    {
                        Banknote = Banknote, Count = value / Banknote.Value
                    }
                }, true);
            }

            if (_nextHandler != null)
            {
                (var money, var success) = _nextHandler.Withdraw(currencyType, value - value / Banknote.Value * Banknote.Value);

                if (success && value / Banknote.Value > 0)
                {
                    money.Add(new BankRoll()
                    {
                        Banknote = Banknote, Count = value / Banknote.Value
                    });
                }

                return(money, success);
            }
            else
            {
                return(null, false);
            }
        }
Esempio n. 2
0
 public (List <BankRoll> money, bool success) Withdraw(CurrencyType currencyType, int value)
 {
     return(_handler.Withdraw(currencyType, value));
 }