Beispiel #1
0
        public bool TakeOrder(TypePizze menu, ref decimal customerMoney, ref decimal companyMoney, Action <Func <AbstractPizza> > CallBackPizza)
        {
            if (menu == TypePizze.None || CheckMoney(menu, ref customerMoney, ref companyMoney) == -1)
            {
                return(false);
            }
            Order.Enqueue(new Order <TypePizze, Action <Func <AbstractPizza> > >(menu, CallBackPizza));

            return(true);
        }
Beispiel #2
0
        private int CheckMoney(TypePizze menu, ref decimal customerMoney, ref decimal companyMoney)
        {
            if (((int)menu) <= customerMoney)
            {
                customerMoney -= (int)menu;
                companyMoney  += (int)menu;

                return(0);
            }
            else
            {
                return(-1);
            }
        }
Beispiel #3
0
        protected AbstractPizza FactoryPizza(TypePizze menu)
        {
            switch (menu)
            {
            case TypePizze.CheesePizze: return(new CheesePizze());

            case TypePizze.HawaiianPizza: return(new HawaiianPizza());

            case TypePizze.MeatPizza: return(new MeatPizza());

            case TypePizze.PepperoniPizza: return(new PepperoniPizza());

            default: return(null);
            }
        }
Beispiel #4
0
        public bool OrderTo(TypePizze menu, ref decimal money, Action <Func <AbstractPizza> > CallBackPizza)
        {
            Cashier cashier = null;

            foreach (var item in Worker)
            {
                if (item is Cashier)
                {
                    cashier = (Cashier)item;
                }
            }

            if (cashier != null)
            {
                return(cashier.TakeOrder(menu, ref money, ref Money, CallBackPizza));
            }

            return(false);
        }
Beispiel #5
0
 public bool OrderPizza(Pizzeria pizzeria, TypePizze pizza)
 {
     return(pizzeria.OrderTo(pizza, ref Money, GetPizza));
 }