Beispiel #1
0
#pragma warning disable CS0246 // The type or namespace name 'Success' could not be found (are you missing a using directive or an assembly reference?)
        /// <summary>
        /// Handles the payment
        /// </summary>
        /// <param name="moneyGiven"></param>
        /// <returns></returns>
        private Success HandlePayment(decimal moneyGiven)
#pragma warning restore CS0246 // The type or namespace name 'Success' could not be found (are you missing a using directive or an assembly reference?)
        {
            decimal valueToReturn = moneyGiven - Cart.GetTransactionValue();

            if (tillDrawer.ContainsEnough(valueToReturn))
            {
                ICashSet givenSet = CashController.SmallestSetForValue(moneyGiven);

                ICashSet availableCash = new CashSet(tillDrawer.DrawerContent);
                availableCash.Add(givenSet);

                ICashSet returnSet = PaymentController.Payout(valueToReturn, availableCash);

                if (returnSet != null)
                {
                    consoleDisplay.Print(string.Format("\nReturn {0}, distributed as: {1}",
                                                       valueToReturn.ToString(),
                                                       returnSet.ToString()));

                    tillDrawer.Add(givenSet);
                    tillDrawer.Remove(returnSet);

                    return(new Success(true));
                }
                else
                {
                    return(new Success(false, "\nUnable to allocate sufficient cash; request a different payment method"));
                }
            }
            else
            {
                return(new Success(false, "\nNot enough money in the drawer; request a different payment method"));
            }
        }
        private static Cocktail Build(CocktailKey key)
        {
            var recipe = BuildRecipe(key);
            var price  = CashController.GetPrice(key);

            return(new Cocktail(key, price, recipe));
        }
Beispiel #3
0
        public void CanMakeSingleTypeLimitedCashSet(decimal value)
        {
            CashSet cashSet = (CashSet)CashController.SmallestSetForValue(value, Mocks.MockCashSets.StandardSet);

            ICash item = (from cashItem
                          in cashSet.CashStack
                          where cashItem.Key.UnitValue == value
                          select cashItem.Key).FirstOrDefault();

            cashSet.CashStack.TryGetValue(item, out int amount);

            Assert.AreEqual(1, amount);
        }
 private void Awake()
 {
     barcontroller  = GameObject.Find("BarController").GetComponent <BarController>();
     cashController = GameObject.Find("CashController").GetComponent <CashController>();
 }