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); }
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); } }
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); } }
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); }
public bool OrderPizza(Pizzeria pizzeria, TypePizze pizza) { return(pizzeria.OrderTo(pizza, ref Money, GetPizza)); }