Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public abstract class Pizza
- {
- public void prepare()
- {
- Console.WriteLine("Preparing " + this.GetType().Name);
- }
- public void bake()
- {
- }
- public void cut()
- {
- }
- public void box()
- {
- }
- }
- public class PizzaStore
- {
- public Pizza orderPizza(string type)
- {
- Pizza pizza = createPizza(type);
- pizza.prepare();
- pizza.bake();
- pizza.cut();
- pizza.box();
- return pizza;
- }
- public Pizza createPizza(string type)
- {
- Pizza pizza = null;
- if (type == "cheese")
- {
- pizza = new CheesePizza();
- }
- else if (type == "pepperoni")
- {
- pizza = new PepperoniPizza();
- }
- else if (type == "clam")
- {
- pizza = new ClamPizza();
- }
- else if (type == "veggie")
- {
- pizza = new VeggiePizza();
- }
- return pizza;
- }
- }
- public class VeggiePizza : Pizza
- {
- }
- public class ClamPizza : Pizza
- {
- }
- public class PepperoniPizza : Pizza
- {
- }
- public class CheesePizza : Pizza
- {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement