Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Questions 15 and 16 refer to the following design problem. You are to create a s

ID: 3839946 • Letter: Q

Question

Questions 15 and 16 refer to the following design problem. You are to create a software design that stimulates a fast food restaurant. You will food items hot dogs, chicken sandwiches) and drink items (Cake, Sprite, root beer). The drinks come in various given in ounces (for example: 12, 24, 48). Food items will be assigned a price when they are created but this price can be changed by the employee taking the items will be assigned according to the size of the drink. Which of the following would be the best choice for the design of this system? Why? a. The design should include the following classes: Hamburger, HotDog, Chicken, Coke, Sprite, and RootBeer. b. The design should include the following classes: Fooditem with Hamburger, HotDog, and Chicken extending FoodItem and DrinkItem with Coke, Sprite, and RootBeer extending DrinkItem. c. The design should include the following classes: Item with FoodItem and DrinkItem extending Item: Hmburgerm HotDog, and Chicken extending FoodItem; and DrinkItem with Coke, Sprite, and RootBeer extending DrinkItem. d. The design should include the following classes: FoodItem and DrinkItem. The individula types of food and drink are only descriptions of the food or drink and should not be separate classes. e. The design should include the following classes: Item with FoodItem and DrinkItem extending Item. The individual types of food and drink are objects that are instances of these classes, not separate classes. The fast food restaurant also offers value meals. A value meal is 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 includes 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 Meal and DeluxeValueMeal.

Explanation / Answer

16.

choice a is best choice for system design. DeluxeValueMeal should be a subclass of ValueMeal.

ValueMeal is a super class of DeluxeValueMeal. So there is inheritance relationship between two classes. The benefit of inheritance is code reusability. So there will be less coding which is good for system design. It will reduce the code lines, which is major task of programmer in system designing. Through inheritance mechanism, a new class is derived from existing class and derived class can inherit the properties and functions of parent class. By adding new features and functionality, a new class is created. The new derived class can use the properties and functions of parent class. There is no need to declare the same data member and member functions again. This saves a lot of code and programmer's effort. So choice a is better for system design.