Question: Hello, I would like your help with adding some code based on the questions. I tried to do it, but I am not sure how

Hello,

I would like your help with adding some code based on the questions.

I tried to do it, but I am not sure how I can put everything. Please review the question attached below as well.

Code:

class Restaurant(object):  _instance = None  _orders = 0  _total_sales = 0  def __new__(cls,*args, **kwargs):    if cls._instance is None:      cls._instance = object.__new__(cls, *args, **kwargs)    return cls._instance  def __str__(self):    return f"orders: {self._orders} Total Sales: {self._total_sales}"   def order_food(self, food_type):    Food.order_food(food_type)         class Food:  @staticmethod  def order_food(food_type):    def __str__ :      food_type = food_type      food = Cheeseburger()    print(food_type)        def __init__(self):    print("it is debugging.")   def price(self):    return food   def prepare(self) 

Question:

Hello, I would like your help with adding some code based on

This class acts as the base class for other concrete Food classes, like Cheeseburger and Pasta (see Part III). As the title hints at, this class will also serve as the factory for those derivative classes. This class should have the following methods: init (self) o This method is mostly a placeholder. You may want to print a message when it is called while debugging. . price(self) O Returns the price of the item. o This is also a placeholder for use by derived classes. It only needs to return 0. . prepare (self) o This method is a placeholder for use by derived classes. o In derived classes, this method acts as a facade that encapsulates the complex process for making this specific food. order_food (food_type) # Notice no 'self' o This method acts as the factory method for making food objects. o This method should be static so mark it with the @staticmethod decorator. Here's the process for kicking off the factory: Make sure food_type is a string and trim and convert it to lower case Create the object of the type called for by the string So if it is "cheeseburger": o food = Cheeseburger() . Once your food object is created, you will call its prepare() method

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!