I am currently writing a program using the decorator pattern. I am trying to find out how to limit the amount of decorators I can add to the first class. Such as:
Pizza plainPizza = new PlainPizza; Pizza sausage = new Sausage(plainPizza);
How could I code this where I can be limited to the amount of decorators I add on. Such as if I try to add this on top of the previous code:
Pizza pepperoni = new Pepperoni(sausage);
How can I prevent it from allowing pepperoni to be added/wrapped?
Thank you!
Aucun commentaire:
Enregistrer un commentaire