Esempio n. 1
0
        public void Process(TableRequests table)
        {
            var chickens = table[typeof(Chicken)];

            for (int i = 0; i < chickens.Length; i++)
            {
                var chicken = (Chicken)chickens[i];
                chicken.Obtain();
                chicken.CutUp();
                chicken.Cook();
            }

            var eggs = table[typeof(Egg)];

            for (int i = 0; i < eggs.Length; i++)
            {
                using (var egg = (Egg)eggs[i])
                {
                    egg.Obtain();
                    try
                    {
                        egg.Crack();
                    }
                    catch
                    {
                    }
                    egg.Cook();
                }
            }
        }
Esempio n. 2
0
        public void Process(TableRequests table)
        {
            var foods = table.Get <Food>();

            foreach (Food food in foods)
            {
                food.Prepare();
            }
            Processed?.Invoke(table);
        }
Esempio n. 3
0
 public void Process(TableRequests table)
 {
     lock (locker)
     {
         l = true;
         var foods = table.Get <Food>();
         Parallel.ForEach(foods, food =>
         {
             Food f = (Food)food;
             f.Prepare();
         });
         Thread.Sleep(30000);
         l = false;
     }
 }
Esempio n. 4
0
        public void Processed(TableRequests tableRequests)
        {
            foreach (KeyValuePair <string, List <IMenuItem> > row in tableRequests)
            {
                var  ch = 0;
                var  e  = 0;
                Type t  = null;

                foreach (IMenuItem value in row.Value)
                {
                    if (value is Chicken)
                    {
                        ch++;
                    }
                    else if (value is Egg)
                    {
                        e++;
                    }
                    else if (value is Drink)
                    {
                        t = value.GetType();
                    }
                }

                var str = $"Customer {row.Key} is served {ch} chicken, {e} egg, ";

                if (t != null)
                {
                    str += $"{t.Name}";
                }
                else
                {
                    str += "no drinks";
                }
                resultOfCooks.Add(str);
            }
            served = false;
            tableRequests.Clear();
        }
Esempio n. 5
0
 public Server()
 {
     cook          = new Cook();
     tableRequests = new TableRequests();
 }
Esempio n. 6
0
 public Server()
 {
     resultOfCooks = new List <string>();
     tableRequests = new TableRequests();
 }