Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class PizzaStore
- {
- public Pizza orderPizza(string type)
- {
- Pizza creatablePizza = createPizza(type);
- creatablePizza.prepare();
- creatablePizza.bake();
- creatablePizza.cut();
- creatablePizza.box();
- return creatablePizza;
- }
- 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 PizzaDecorator : Pizza
- {
- protected Pizza pizza;
- public PizzaDecorator(Pizza pizza)
- {
- this.pizza = pizza;
- }
- public override void prepare()
- {
- pizza.prepare();
- }
- }
- public class CheeseAroundPizza : PizzaDecorator
- {
- public CheeseAroundPizza(Pizza pizza) : base(pizza)
- {
- Name = pizza.Name + "with cheese Around";
- Cost = pizza.Cost + 5;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement