Esempio n. 1
0
        public IEnumerable <Money> Eject(CashDeal inCash, ChangePool inReservedMoney)
        {
            try {
                if (inCash.UsedAmount == 0)
                {
                    return(inCash.RecevedMoney.ToList());
                }

                var result = new List <KeyValuePair <Money, int> >();

                this.EjectCore(
                    inCash.ChangedAount,
                    inReservedMoney.Items.OrderByDescending(pair => pair.Key.Value()),
                    (m, totalCount, useCount) => {
                    result.Add(
                        new KeyValuePair <Money, int>(m, (int)useCount)
                        );
                }
                    );

                return(result.SelectMany(r => Enumerable.Repeat(r.Key, r.Value)));
            }
            finally {
                inCash.RecevedMoney.Clear();
            }
        }
Esempio n. 2
0
        public IEnumerable<Money> Eject(CashDeal inCash, ChangePool inReservedMoney)
        {
            try {
                if (inCash.UsedAmount == 0) {
                    return inCash.RecevedMoney.ToList();
                }

                var result = new List<KeyValuePair<Money, int>>();

                this.EjectCore(
                    inCash.ChangedAount,
                    inReservedMoney.Items.OrderByDescending(pair => pair.Key.Value()),
                    (m, totalCount, useCount) => {
                        result.Add(
                            new KeyValuePair<Money, int>(m, (int)useCount)
                        );
                    }
                );

                return result.SelectMany(r => Enumerable.Repeat(r.Key, r.Value));
            }
            finally {
                inCash.RecevedMoney.Clear();
            }
        }
Esempio n. 3
0
        public PurchaseContext(ChangePool inChanges, ItemRackPosition inItems)
        {
            mDealAmount = new CashDeal();
            mChanges    = inChanges;
            mItems      = inItems;

            mCoinMeckRole = new CoinMeckRole();
            mItemRole     = new ItemRackRole();
        }
Esempio n. 4
0
        public PurchaseContext(ChangePool inChanges, ItemRackPosition inItems)
        {
            mDealAmount = new CashDeal();
            mChanges = inChanges;
            mItems = inItems;

            mCoinMeckRole = new CoinMeckRole();
            mItemRole = new ItemRackRole();
        }
Esempio n. 5
0
        public bool UpdateItemSelectionState(ItemRack inRack, CashDeal inCredits, ChangePool inPool)
        {
            var oldState = inRack.State;
            if (oldState == ItemRackState.Soldout) return false;

            if (inRack.Item.Price <= (inCredits.RecevedMoney.TotalAmount() - inCredits.UsedAmount)) {
                inRack.State = ItemRackState.CanPurchase;
            }

            return oldState != inRack.State;
        }
Esempio n. 6
0
        public bool UpdateItemSelectionState(ItemRack inRack, CashDeal inCredits, ChangePool inPool)
        {
            var oldState = inRack.State;

            if (oldState == ItemRackState.Soldout)
            {
                return(false);
            }

            if (inRack.Item.Price <= (inCredits.RecevedMoney.TotalAmount() - inCredits.UsedAmount))
            {
                inRack.State = ItemRackState.CanPurchase;
            }

            return(oldState != inRack.State);
        }