Exemple #1
0
 public virtual void CalculateBanknotes(ref Money requestedMon)
 {
     if (_nextHandler != null)
     {
         _nextHandler.CalculateBanknotes(ref requestedMon);
     }
 }
Exemple #2
0
        public string GetMoney(string requestedMoney)
        {
            string[] moneyMasStr = requestedMoney.Split(' ');
            if (moneyMasStr.Length > 2)
            {
                return("Некорректно введена запрашиваемая сумма");
            }
            int requestedMoneyInt;
            var isMoneyParsed = int.TryParse(moneyMasStr[0], out requestedMoneyInt);
            var money         = new Money(moneyMasStr[1], moneyMasStr[0]);

            _handler = new TenRubleHandler(null);
            _handler = new FiftyRubleHandler(_handler);
            _handler = new HundredRubleHandler(_handler);
            _handler = new FiveHundredRubleHandler(_handler);
            _handler = new ThousandRubleHandler(_handler);
            _handler = new FiveThousandRubleHandler(_handler);
            _handler = new TenDollarHandler(_handler);
            _handler = new FiftyDollarHandler(_handler);
            _handler = new HundredDollarHandler(_handler);
            _handler = new FiveHundredDollarHandler(_handler);
            _handler = new InvalidValueHandler(_handler);

            _handler.CalculateBanknotes(ref money);
            return(money.BanknotesToUser);
        }