Questions 15 and 16 refer to the following design problem. You are to create a s
ID: 3840008 • Letter: Q
Question
Questions 15 and 16 refer to the following design problem. You are to create a software design that simulates a fast food restaurant. You will have food items (hamburgers, hot dogs, chicken sandwiches) and drink items (Coke, sprite, root beer). The drinks come in various sizes 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 DtrinkItem with Coke, Sprite, and RootBeer extending DrinkItem. c. The design should include the following classes: Item with FoodItem and DrinkItem extending Item: Hamburger, HotDog, and Checken extending FoodItem; and DrinkItem with Coke, sprite, and RootBeer extending DrinkItem. d. The design should include the following classes: FoodItem and DrinkItem. The individual 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 drink and a food item at 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 ofExplanation / Answer
15)
option (a) is not correct choice because maintaining separate classes for each item is not good since multiple instances need to create every time.
option (b) is good choice but not correct since here common property for food item and drinks are missing.
option (c) is correct answer since here maintaining common property as name in Item class and then extending foodItem and DrinkItem to separate them.
option (d) is not correct since again same explanation. missing common property.
option (e) keeping all items as instances will reduce flexibility to create and use them.
So finally option (c) is best chioce
----------------------------------------------------------------------------------------------------------------------------------------------------------------
HERE IS THE DESIGN SAMPLE
class Item {
String name;
double price;
}
class FoodItem extends Item {
int size;
FoodItem (String name,double price,int size){
super(name,price);
this.size = size;
}
}
class DrinkItem extends Item {
int ounces;
FoodItem (String name,double price,int ounces){
super(name,price);
this.ounces = ounces;
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.