Exemplo n.º 1
0
        /// <summary>
        ///     Grabs all missing meals as soon as possible.
        /// </summary>
        private void GrabMissingMeals()
        {
            var changedEntries = new Dictionary <MealTypes, int>();

            while (_restOrder.Count > 0)
            {
                Thread.Sleep(Constants.CashierGrabMealRetryTimeoutMs);
                Console.WriteLine(@"Cashier {0} has pending meals. Retrying....", _employeeName);

                foreach (var orderEntry in _restOrder.Where(x => x.Value > 0))
                {
                    ICook cook = _cooks[orderEntry.Key];
                    int   takenCount;
                    cook.TryGetMeals(orderEntry.Value, out takenCount);
                    changedEntries.Add(orderEntry.Key, orderEntry.Value - takenCount);
                }

                //clean _restOrder collection from outside to avoid CollectionChanged exception.
                foreach (var changedEntry in changedEntries)
                {
                    _restOrder[changedEntry.Key] = changedEntry.Value;
                    if (changedEntry.Value == 0)
                    {
                        _restOrder.Remove(changedEntry.Key);
                    }
                }
                changedEntries.Clear();
            }
            _restOrder.Clear();
            Console.WriteLine(@"Order for client {0} is completed.", _currentClient.ClientId);
        }
Exemplo n.º 2
0
        public void Setup(ICook cook)
        {
            foreach(var drink in cook.Drinks)
            {
                var drinkView = new DrinkView();
                this._panel.Controls.Add(drinkView);
                drinkView.Setup(new DrinkViewItem(drink));

                drinkView.BuyClicked += drinkView_BuyClicked;
            }
        }
Exemplo n.º 3
0
        public void Setup(ICook cook)
        {
            foreach (var drink in cook.Drinks)
            {
                var drinkView = new DrinkView();
                this._panel.Controls.Add(drinkView);
                drinkView.Setup(new DrinkViewItem(drink));

                drinkView.BuyClicked += drinkView_BuyClicked;
            }
        }
Exemplo n.º 4
0
        public ActionResult Cook(int id, string action)
        {
            IDictionary <int, Applience> applienceDictionary = (SortedDictionary <int, Applience>)Session["Apps"];
            ICook app = applienceDictionary[id] as ICook;

            if (action == "Food")
            {
                app.Food = true;

                app.Cook();
            }
            return(RedirectToAction("Index"));
        }
Exemplo n.º 5
0
        public Operation(
            IWallet userWallet, 
            IWallet machineWallet, 
            ICook cook)
        {
            if(userWallet == null)
            {
                throw new ArgumentNullException();
            }
            if (machineWallet == null)
            {
                throw new ArgumentNullException();
            }
            if(cook == null)
            {
                throw new ArgumentNullException();
            }

            this.UserWallet = userWallet;
            this.MachineWallet = machineWallet;
            this.Cook = cook;
        }
Exemplo n.º 6
0
        public Operation(
            IWallet userWallet,
            IWallet machineWallet,
            ICook cook)
        {
            if (userWallet == null)
            {
                throw new ArgumentNullException();
            }
            if (machineWallet == null)
            {
                throw new ArgumentNullException();
            }
            if (cook == null)
            {
                throw new ArgumentNullException();
            }

            this.UserWallet    = userWallet;
            this.MachineWallet = machineWallet;
            this.Cook          = cook;
        }
Exemplo n.º 7
0
        /// <summary>
        ///     Tries to gather next client's order.
        /// </summary>
        public void TryToGatherOrder()
        {
            _currentClient = _line.Dequeue();

            foreach (var mealCountPair in _currentClient.Order.Where(order => order.Value > 0))
            {
                int takenCount;

                ICook cook = _cooks[mealCountPair.Key];

                #region log4net[debug]

                log.Debug(Id + " try to get " + mealCountPair.Value + " " + mealCountPair.Key);

                #endregion


                if (!cook.TryGetMeals(mealCountPair.Value, out takenCount))
                {
                    _restOrder.Add(mealCountPair.Key, mealCountPair.Value - takenCount);
                }
            }
        }
Exemplo n.º 8
0
 public Restaurant(string name, ICook chef)
 {
     Name = name;
     Chef = chef;
 }
Exemplo n.º 9
0
 protected BaseCommand(ICook cook) => _cook = cook;
 public Restaurant(string name, ICook cook)
 {
     this.Name = name;
     this.chef = cook;
 }
Exemplo n.º 11
0
 public void SetUp()
 {
     _cook       = Substitute.For <ICook>();
     _accounting = Substitute.For <IAccounting>();
     _waiter     = new Waiter(_cook, _accounting);
 }
Exemplo n.º 12
0
 static void Cook(ICook cook)
 {
     cook.Cook("");
 }
Exemplo n.º 13
0
 public Stove(ICook cook, IBake bake)
 {
     _cook = cook;
     _bake = bake;
 }
Exemplo n.º 14
0
 public Program(ICook cook)
 {
     this.cook = cook;
 }
Exemplo n.º 15
0
 public void SetStrategy(ICook cookStrategy)
 {
     cookStrategy.Cook(_food);
 }
Exemplo n.º 16
0
 public Waiter(ICook cook, IAccounting accounting)
 {
     _cook       = cook;
     _accounting = accounting;
 }