Exemple #1
0
        private string _Cash(int value)
        {
            var alreadyCached = new List <Tuple <int, int> >();
            var result        = _handler.Cash(alreadyCached, value);
            var toCash        = result.Item1;
            var remain        = result.Item2;

            return(remain == 0 ? GetCashedBanknotes(toCash) : "Sorry, dude, we can't cash it. Too bad");
        }
Exemple #2
0
        public virtual Tuple <List <Tuple <int, int> >, int> Cash(List <Tuple <int, int> > alreadyCached, int value)
        {
            var banknoteCount = value / BanknoteValue;
            var remain        = value - banknoteCount * BanknoteValue;

            alreadyCached.Add(Tuple.Create(BanknoteValue, banknoteCount));
            return(_nextHandler == null
                ? Tuple.Create(alreadyCached, remain)
                : _nextHandler.Cash(alreadyCached, remain));
        }