I am trying to make a pizzashop program. I am using the decorator pattern for this purpose. Simply my program is running like this line :
Pizza basicPizza = new TomatoSauce(new Mozzarella(new PlainPizza()));
For every different topping or different sauce I want to get these information from the user. For instance if user enters "Salami,Cheese" i want this line of code:
Pizza basicPizza = new Salami(new Cheese(new PlainPizza()));
I found some information about reflection also newInstance() method but could not achieve my goal because of the inner classes.
Aucun commentaire:
Enregistrer un commentaire