Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello, In this project, I need to use several design patterns together to emulate a task - a restaurant creating meals for customers. It requires

Hello,

In this project, I need to use several design patterns together to emulate a task - a restaurant creating meals for customers.

It requires a decent understanding of the design patterns employed:

  • Singleton: A class of which only a single instance can exist
  • Factory: Creates an instance of several derived classes
  • Faade: Wrap a complicated subsystem with a simpler interface

Would anyone please help me with this question?

Here I coded some but I am not sure if I am following the question...

from math import pi class Restaurant(): def __new__(cls, *args, **kwargs): def __str__(self): return f"{__class__.__name__}: ({self.x}, {self.y}) r: {self.radius}" class Food(): def order_food(self, food_type): self.food_type = food_type 

The question:

image text in transcribed

image text in transcribed

The singleton class for this lab is called Restaurant. The idea is that there can only ever be one restaurant that the customer goes to. It will have at least the following methods: o o O o _new_(cls, *args, **kwargs) This method intercepts any call where a new Restaurant is being created. Use the Singleton creational design pattern example to ensure only one instance of Restaurant is ever created and return that instance. Optionally, assign two variables to that instance called _orders and _total_sales that will keep track of the number of orders placed in the restaurant and their cumulative price. This will be part of the extra credit. _str__(self) This is only used in the extra credit portion of the assignment. If attempted, return a string that informs the user how many orders were placed and how much money the restaurant brought in. Use the variables discussed in the __new_() method. order_food(self, food_type) This method is the gateway to the factory design pattern. For now, the only thing you can effectively put in this method is reference to code that will be added later. Looking forward, it will call the static order_food method of the Food class, passing it food_type as its only argument. O . o o O o Additionally, this is where you will have to alter the _orders and _total_sales variables if you are going down that route. The singleton class for this lab is called Restaurant. The idea is that there can only ever be one restaurant that the customer goes to. It will have at least the following methods: o o O o _new_(cls, *args, **kwargs) This method intercepts any call where a new Restaurant is being created. Use the Singleton creational design pattern example to ensure only one instance of Restaurant is ever created and return that instance. Optionally, assign two variables to that instance called _orders and _total_sales that will keep track of the number of orders placed in the restaurant and their cumulative price. This will be part of the extra credit. _str__(self) This is only used in the extra credit portion of the assignment. If attempted, return a string that informs the user how many orders were placed and how much money the restaurant brought in. Use the variables discussed in the __new_() method. order_food(self, food_type) This method is the gateway to the factory design pattern. For now, the only thing you can effectively put in this method is reference to code that will be added later. Looking forward, it will call the static order_food method of the Food class, passing it food_type as its only argument. O . o o O o Additionally, this is where you will have to alter the _orders and _total_sales variables if you are going down that route

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Learning MySQL Get A Handle On Your Data

Authors: Seyed M M Tahaghoghi

1st Edition

0596529465, 9780596529468

More Books

Students also viewed these Databases questions