Question
The fast food restaurant also offers value meals. A value meal a drink and a food item purchased at the same time. A 10% discount off the full price of purchasing each separately is applied to the price of a value meal. A deluxe value meal costs $0.50 more than a value meal and includes apple pie for dessert. Which of the following is the best choice for this system design? Why? a. DeluxeValueMeal should be a subclass of ValueMeal. b. ValueMeal should be a subclass of DeluxeValueMeal. c. Both DeluxeValueMeal and ValueMeal should be separate classes that have no inheritance relationship. d. ValueMeal has an association (has-a) relationship with DeluxeValueMeal. e. ValueMeal and DeluxeValueMeal both have an instance field of type Meal which is a superclass of both value Meal and DeluxeValueMeal.
Explanation / Answer
a. DeluxeValueMeal should be a subclass of ValueMeal
The reason is that DeluxeValueMeal adds more functionality to the ValueMeal. ValueMeal provides 10% discount off the full-pricing and DeluxeValueMeal does the same but adds it's own features too.