Example #1
0
        //an entire order
        public double PlaceOrder(string cType, string nyType, List<string> coffeeOrder, string duckOrder)
        {
            double orderTotal = 0;
            Pizza chiPizza, nyPizza;
            PizzaStore chiPizzaStore;
            PizzaStore nyPizzaStore;
            DuckOven woodOven;
            DuckOven grillOven;
            Duck delicious;

            //chicago pizza
            if (cType != "none")
            {
                chiPizzaStore = new ChicagoPizzaStore();
                chiPizza = chiPizzaStore.OrderPizza(cType);
                orderTotal += chiPizza.Cost;
            }

            //ny pizza
            if (nyType != "none")
            {
                nyPizzaStore = new NYPizzaStore();
                nyPizza = nyPizzaStore.OrderPizza(nyType);
                orderTotal += nyPizza.Cost;
            }

            //coffee
            if (coffeeOrder != null)
            {
                Beverage coffee;
                bool first = true;

                coffee = new Espresso();
                foreach (string bev in coffeeOrder)
                {
                    if (first)
                    {
                        coffee = makeBaseCoffee(bev);
                        first = false;
                    }
                    else
                    {
                        coffee = decorateCoffee(bev, coffee);
                    }
                }
                orderTotal += coffee.Cost;
            }

            //duck
            if (duckOrder == "Roasted")
            {
                woodOven = new WoodDuckOven();
                delicious = woodOven.CookDuck(duckOrder);
                orderTotal += delicious.Cost;
            }
            else if (duckOrder == "BBQ" || duckOrder == "Peking")
            {
                grillOven = new GrillDuckOven();
                delicious = grillOven.CookDuck(duckOrder);
                orderTotal += delicious.Cost;
            }

            salesTotal += orderTotal;       //update salesTotal
            NotifyObserver(salesTotal, orderTotal);      //notify observers

            return orderTotal;
        }
Example #2
0
 private Beverage makeBaseCoffee(string bev)
 {
     Beverage coffee;
     switch (bev)
     {
         case "DarkRoast":
             coffee = new DarkRoast();
             break;
         case "Decaf":
             coffee = new Decaf();
             break;
         case "Espresso":
             coffee = new Espresso();
             break;
         case "HouseBlend":
             coffee = new HouseBlend();
             break;
         default:                //invalid base
             coffee = null;
             break;
     }
     return coffee;
 }