public string PrepareFood() { if (order is ChickenOrder) { ChickenOrder c = (ChickenOrder)order; for (int i = 0; i < c.GetQuantity(); i++) { c.CutUp(); } c.Cook(); return("indicating preparation has been completed"); } else if (order is EggOrder) { var rotten = 0; EggOrder e = (EggOrder)order; for (int i = 0; i < e.GetQuantity(); i++) { try { e.Crack(); } catch { rotten++; } e.DiscardShell(); } e.Cook(); return("indicating preparation has been completed " + rotten.ToString()); } throw new Exception("Hey Guy You haven't instance!"); }
static void Main(string[] args) { Customer customer = new Customer(); Cook cook = new Cook(); Waiter waiter = new Waiter(); Console.WriteLine("Welcome to the restaurant. Press 's' to order soup, and 'c' to order chicken."); IOrder order; switch (customer.GetDish()) { case Dish.Chicken: order = new ChickenOrder(cook); break; case Dish.Soup: order = new SoupOrder(cook); break; default: throw new Exception(); } waiter.TakeOrder(order); waiter.StartOrder(); }