Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please help me with these questions. The following clasces repesent reed itens at Pallark Dining Commons that students put in their food Elwax Thed: name
Please help me with these questions.
The following clasces repesent reed itens at Pallark Dining Commons that students put in their food Elwax Thed: name 3 a:z priae_per_unit 3 int lelaat food_1ter_1 - Tooditonut, 1.5) s frot 1tma. 1. caxt 1} 1. 3 sys fuoi_ibua.2.6unt1) det cost {3elf}; zeturn selt.frdoe_per_unit :lua Ifuy: "an rso food_1ter.1 = Food'Ionut", 1.5) bi ny_oresctast - Irsy } S3y ry_brmaifat.med_ta_tray (fead__tw_1) wor ny_oyeaxfaat.add_to_tray (food__tea_2) so: ay_secuifeat.ads_to_tay (foad_-tea_l P n__oresctast,scd_to_tray(tood_ten_l b>s ry bemicfant. 12man [Mod nimects, epond abdectis, 0.85. Hot drinks should have a class variable and have the cost equal to the price of the drink plus this price. Finally, implement a class. A is separate from a , and stores at most one food and one drink item. If you try to add more, you will get an error message. Some sample functionality is provided below: > new_plate = Plate () > soda = Drink("Pepsi", 2) >> snack = Snack("Pretzel", 3) new_plate.add_item(soda) Added successfully. new_plate.add_item(snack) Added successfully. new_plate.add_item(soda) This plate already has a drink. Assume that all these classes are written such that they appropriately use the design principles discussed in Module 3.2 (inheritance and polymorphism). Remember that inheritance allows the subclass to use the same blueprint of the parent class just by including the parent class name in the subclass definition. Do not repeat unnecessary code that is already available. Answer the following questions to demonstrate your understanding of these properties. You are highly encouraged (but not required) to write out the code for this problem to aid your answering. >issubclass(HotDrink,Food) > issubclass (Drink, Main) >> issubclass(Plate, Food) > issubclass (Plate, Tray) Which methods should be defined in each class? Remember that we are assuming proper design principles, not repeating code whenever possible. Drink Hot Drink Main Snack Assume that the initialization method of a item was accidentally modified in a way that causes an error whenever it is run. Instances of which classes could successfully be created despite this mistake? Plate HotDrink Snack Drink Main Food Suppose you wanted to abstract and further, which of the following ideas would make the most sense? Creating two new classes, one that will be a parent class of and the other a parent class of and implementing the item limiting within them Creating two new classes, one that will be a subclass of and the other a subclass of and implementing the item limiting within them Creating a class that inherits from both and Creating a class that is a parent class for both The following clasces repesent reed itens at Pallark Dining Commons that students put in their food Elwax Thed: name 3 a:z priae_per_unit 3 int lelaat food_1ter_1 - Tooditonut, 1.5) s frot 1tma. 1. caxt 1} 1. 3 sys fuoi_ibua.2.6unt1) det cost {3elf}; zeturn selt.frdoe_per_unit :lua Ifuy: "an rso food_1ter.1 = Food'Ionut", 1.5) bi ny_oresctast - Irsy } S3y ry_brmaifat.med_ta_tray (fead__tw_1) wor ny_oyeaxfaat.add_to_tray (food__tea_2) so: ay_secuifeat.ads_to_tay (foad_-tea_l P n__oresctast,scd_to_tray(tood_ten_l b>s ry bemicfant. 12man [Mod nimects, epond abdectis, 0.85. Hot drinks should have a class variable and have the cost equal to the price of the drink plus this price. Finally, implement a class. A is separate from a , and stores at most one food and one drink item. If you try to add more, you will get an error message. Some sample functionality is provided below: > new_plate = Plate () > soda = Drink("Pepsi", 2) >> snack = Snack("Pretzel", 3) new_plate.add_item(soda) Added successfully. new_plate.add_item(snack) Added successfully. new_plate.add_item(soda) This plate already has a drink. Assume that all these classes are written such that they appropriately use the design principles discussed in Module 3.2 (inheritance and polymorphism). Remember that inheritance allows the subclass to use the same blueprint of the parent class just by including the parent class name in the subclass definition. Do not repeat unnecessary code that is already available. Answer the following questions to demonstrate your understanding of these properties. You are highly encouraged (but not required) to write out the code for this problem to aid your answering. >issubclass(HotDrink,Food) > issubclass (Drink, Main) >> issubclass(Plate, Food) > issubclass (Plate, Tray) Which methods should be defined in each class? Remember that we are assuming proper design principles, not repeating code whenever possible. Drink Hot Drink Main Snack Assume that the initialization method of a item was accidentally modified in a way that causes an error whenever it is run. Instances of which classes could successfully be created despite this mistake? Plate HotDrink Snack Drink Main Food Suppose you wanted to abstract and further, which of the following ideas would make the most sense? Creating two new classes, one that will be a parent class of and the other a parent class of and implementing the item limiting within them Creating two new classes, one that will be a subclass of and the other a subclass of and implementing the item limiting within them Creating a class that inherits from both and Creating a class that is a parent class for bothStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started