コード例 #1
0
        public Pizza CreatePizza(string type)
        {
            Pizza pizza = null;

            switch (type)
            {
            case "cheese":
                pizza = new CheesePizza();
                break;

            case "pepperoni":
                pizza = new PepperoniPizza();
                break;

            case "clam":
                pizza = new ClamPizza();
                break;

            case "veggie":
                pizza = new VeggiePizza();
                break;
            }
            Console.WriteLine(pizza);
            return(pizza);
        }
コード例 #2
0
ファイル: PizzaTestDrive.cs プロジェクト: ronymaychan/demos
 public Pizza CreatePizza(string type)
 {
     Pizza pizza = null;
     switch (type)
     {
         case "cheese": pizza = new CheesePizza(); break;
         case "pepperoni": pizza = new PepperoniPizza(); break;
         case "clam": pizza = new ClamPizza(); break;
         case "veggie": pizza = new VeggiePizza(); break;
     }
     Console.WriteLine(pizza);
     return pizza;
 }