To be honest, this is a matter of homework, so I will tell you my opinion. Can you tell me your mistakes and not give me a solution?
This is the question:
Imagine a restaurant that offers only the following two types of food: (a) full lunch and (b) housekeeping. A complete meal consists of the following foods and is served in the following order: 1. Appetizer 2. Drink 3. Main course 4. Dessert Meanwhile, household food consists of the following foods and is served in the following order: 1. Drink 2. Main course
Determine the most appropriate design pattern that can be used to allow the customer to only order using one of two types of meals and that the food components should be served in that order.
I got confused between Factory and Iterator and used them together. Using the Factory template, we can create a complete and economical power supply and provide the user with a base class of objects that will be solved. But how can we ensure the ordering of the elements, I thought about using an iterator that will go through a composition of two created factories, like saying.
What do you think?
design-patterns software-design
Iyad al aqel
source share