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); }
protected BanknoteHandler(BanknoteHandler nextHandler) { _nextHandler = nextHandler; }
public TenDollarHandler(BanknoteHandler nextHandler) : base(nextHandler) { }
public HundredDollarHandler(BanknoteHandler nextHandler) : base(nextHandler) { }
public FiftyDollarHandler(BanknoteHandler nextHandler) : base(nextHandler) { }
public TenRubleHandler(BanknoteHandler nextHandler) : base(nextHandler) { }
protected DollarHandlerBase(BanknoteHandler nextHandler) : base(nextHandler) { }
public FiftyRubleHandler(BanknoteHandler nextHandler) : base(nextHandler) { }
public HundredRubleHandler(BanknoteHandler nextHandler) : base(nextHandler) { }
public ThousandRubleHandler(BanknoteHandler nextHandler) : base(nextHandler) { }
protected RubleHandlerBase(BanknoteHandler nextHandler) : base(nextHandler) { }
public InvalidValueHandler(BanknoteHandler nextHandler) : base(nextHandler) { }