Question

In: Computer Science

Simulate a fast-food ordering scenario by defining four Python classes: a) Lunch: Main class b) Customer:...

Simulate a fast-food ordering scenario by defining four Python classes: a) Lunch: Main class b) Customer: the person that buys food c) Employee: the person that accepts a customer order d) Food: what the customer buys

Create all the classes in one module and a separate test module where instances of the class are created, and the methods are tested with appropriate instances. To start, here are the classes and methods you should define and complete:

class Lunch:

def __init__(self) # include Customer and Employee

def order(self, foodName)# start a Customer order simulation

def result(self) # Ask the Customer food preference

class Customer:

def __init__(self) # initialize my food to None

def placeOrder(self, foodName, emp) # place order from Employee

def printFood(self) # print the name of my food

class Employee:

def takeOrder(self, foodName) # return name of Food requested

class Food: def __init__(self, name) # store food name

The simulation works as follows:

a. The Lunch class’s constructor should make and embed an instance of Customer and Employee, and export a method called order. When called, this order method should ask the Customer to place an order, by calling its placeOrder method. The Customer’s placeOrder method should in turn ask the Employee object for a new Food object, by calling the Employee’s takeOrder method.

b. Food objects should store a food name string (e.g., "biryani"), passed down from objects of Lunch.order to Customer.placeOrder, to Employee.takeOrder, and finally to Food’s constructor. The top-level Lunch class should also export a method called result, which SWE 321 – OOP Lab. College of Technological Innovations (CTI) 21 asks the customer to print the name of the food it received from the Employee via the order (this can be used to test your simulation).

c. Note that Lunch needs to either pass the Employee to the Customer, or pass itself to the Customer, in order to allow the Customer to call Employee methods

d. Experiment with your classes interactively by importing the Lunch class, calling its order method to run an interaction, and then calling its result method to verify that the Customer got what he or she ordered.

e. In this simulation, the Customer is the active agent; how would your classes change if Employee were the object that initiated customer/ employee interaction instead?

Solutions

Expert Solution

Hello dear,

PLEASE UPVOTE IF THIS ANSWER SEEMS HELPFUL AS IT GIVES THE CONFIDENCE TO HELP MORE STUDENTS

THANKYOU

class Lunch:
def __init__(self):
self.customer = Customer()
self.employee = Employee()
def order(self, foodName):
print('order is %s' % (foodName))
self.customer.placeOrder(foodName, self.employee)
def result(self):
self.customer.printOrder(self.employee)

class Customer:
def __init__(self):
self.food = None
def placeOrder(self, foodName, employee):
print('\tplace Order')
employee.takeOrder(foodName)
def printOrder(self, employee):
print(employee.getNameFood())
  

class Employee:
def takeOrder(self, foodName):
print('\t\ttake Order')
self.food = Food(foodName)
def getNameFood(self):
return self.food.name

class Food:
def __init__(self, name):
self.name = name

if __name__ == '__main__':
lunch = Lunch()
lunch.order('biryani')
lunch.result()

SCREENSHOT OF PROGRAM AND OUTPUT

PLEASE GIVE IT A THUMBS UP, I SERIOUSLY NEED ONE, IF YOU NEED ANY MODIFICATION THEN LET ME KNOW, I WILL DO IT FOR YOU


Related Solutions

Simulate a fast-food ordering scenario by defining four Python classes: a) Lunch: Main class b) Customer:...
Simulate a fast-food ordering scenario by defining four Python classes: a) Lunch: Main class b) Customer: the person that buys food c) Employee: the person that accepts a customer order d) Food: what the customer buys Create all the classes in one module and a separate test module where instances of the class are created, and the methods are tested with appropriate instances. To start, here are the classes and methods you should define and complete: class Lunch: def __init__(self)...
Q- Below is a project requirement for Online ordering system for fast food restaurant(where customer order...
Q- Below is a project requirement for Online ordering system for fast food restaurant(where customer order through app/online) Object-oriented design project: Table of Contents 1- Introduction; 2- Project Plan; 3- Functional Specifications (including descriptions of Actors/Roles; Business Rules; 3.1- Use-Case Diagrams with Use-Case descriptions; Examples of Class Diagrams (related to particular Use Cases); 3.2- Examples of Object Diagrams [related to the selected Class Diagrams]; 3.3- Examples of Sequence Diagrams; 3.4- Examples of Collaboration or Communication Diagrams; 3.5- Examples of State-Chart...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT