What design pattern shall I use in this question?

Posted by iyad al aqel on Stack Overflow See other posts from Stack Overflow or by iyad al aqel
Published on 2011-01-09T12:37:45Z Indexed on 2011/01/09 13:53 UTC
Read the original article Hit count: 256

To be frank, this is a homework question, so I'll tell you my opinion. Can you let me know my mistakes rather than giving me the solution?

This is the question :

Assume a restaurant that only offers the following two types of meals: (a) a full meal and (b)an economic meal. The full meal consists of the following food items and is served in the following order: 1. Appetizer 2. Drink 3. Main dish 4. Dessert Meanwhile the economic meal consists of the following food items and is served in the following order: 1. Drink 2. Main dish

Identify the most appropriate design pattern that can be used to allow a customer to only order using one of the two types of meals provided and that the meal components must be served in the given order.

I'm confused between the Factory and the Iterator and using them both together. Using the factory Pattern we can create the two meals full and economic and provide the user with with a base object class that will decide upon. But how can we enforce the ordering of the elements, I thought of using the iterator along that will iterate through the the composite of the two created factories sort of speak.

What do you think?

© Stack Overflow or respective owner

Related posts about homework

Related posts about design-patterns