示例#1
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);
        }
示例#2
0
 protected BanknoteHandler(BanknoteHandler nextHandler)
 {
     _nextHandler = nextHandler;
 }
示例#3
0
 public TenDollarHandler(BanknoteHandler nextHandler) : base(nextHandler)
 {
 }
示例#4
0
 public HundredDollarHandler(BanknoteHandler nextHandler) : base(nextHandler)
 {
 }
示例#5
0
 public FiftyDollarHandler(BanknoteHandler nextHandler) : base(nextHandler)
 {
 }
示例#6
0
 public TenRubleHandler(BanknoteHandler nextHandler) : base(nextHandler)
 {
 }
示例#7
0
 protected DollarHandlerBase(BanknoteHandler nextHandler) : base(nextHandler)
 {
 }
示例#8
0
 public FiftyRubleHandler(BanknoteHandler nextHandler) : base(nextHandler)
 {
 }
示例#9
0
 public HundredRubleHandler(BanknoteHandler nextHandler) : base(nextHandler)
 {
 }
示例#10
0
 public ThousandRubleHandler(BanknoteHandler nextHandler) : base(nextHandler)
 {
 }
示例#11
0
 protected RubleHandlerBase(BanknoteHandler nextHandler) : base(nextHandler)
 {
 }
示例#12
0
 public InvalidValueHandler(BanknoteHandler nextHandler) : base(nextHandler)
 {
 }