Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is a restaurant simulation. We need to create a class? Instructions are below Menuhemass - Start by dening the MenuItem class in a file

This is a restaurant simulation. We need to create a class? Instructions are below

image text in transcribedimage text in transcribedimage text in transcribed
Menuhemass - Start by dening the MenuItem class in a file titled MenuItem . py. - This class will represent a single item that a diner can order from the restaurant's menu. a The class will use the following instance attributes: 0 self. name: a string representing the name of the MenuIteIn 0 self .type: a string representing the type of item 0 self. price: a oat representing the price of the item 0 self .description: a string containing a description of the item 0 Also define the following methods: 0 _init_ I Inputs [4): the name (string), type (string), price (oat), and description (string) of the dish I Return value: none I Assign the inputs to the 4 instance attributes listed above. I Note: "type" is a Python keyword, so avoid naming any variables "type". 0 Dene getters and setters for each of the 4 attributes. You should have 4 getters and 4 setters. Note that not all of these may be used. 0 _str_ I inputs: none I Return value: a string I Construct a message containing all 4 attributes, formatted in a readable manner. For example: Fresh Spring Rolls (Appetizer): $3.99 4 vegetarian rolls wrapped in rice paper either fresh or fried Menu Class 0 Next, define the Menu class in a le titled Menu . py. This class will make use of Menultem objects, so be sure to include the proper import statement. 0 This class represents the restaurant's menu which contains four different categories of menu items diners can order from. o The class will have a single class (or static) variable: 0 MENU_ITEM_TYPES: a list containing 4 strings, representing the 4 possible types of menu items: "Drink", "Appetizer\. The class will use the following instance attribute: o self. menuItemDrinkList: a list containing all the drink menu items from the menu o self. menuItemAppetizerList: a list containing all the appetizer menu items from the menu o self. menuItemEntreeList: a list containing all the entree menu items from the menu o self. menuItemDessertList: a list containing all the dessert menu items from the menu o Extra credit . Instead of four lists, you can use a single dictionary self. menuItemDictionary: a dictionary containing all the menu items from the menu. The keys are strings representing the types of the menu item, and the values are a list of MenuItem objects. . Define the following methods: o init_ Inputs (1): a string representing the name of the csv file that contains information about the menu items for the restaurant's menu Return value: none Initialize the single instance attribute to an empty list. Open and read the csv file and create a MenuItem object from each line in the file. Use the type to add the new object to one of the menuItemLists. Note that each line in the file contains the 4 pieces of information needed to create a MenuItem object. Close the file object. o getMenuItem " Inputs (2): a string representing a type of menu item (will be one of the four types listed in MENU_ITEM_TYPES) and an integer representing the index position of a certain menu item Return value: a MenuItem object from one of the four menuItem lists Get the correct MenuItem from the lists using its type and index position in the list of items. o printMenuItemsByType " Inputs (1): a string representing a type of menu item (will be one of the four types listed in MENU_ITEM_TYPES) Return value: None Print a header with the type of menu items, followed by a numbered list of all the menu items of that type. o getNumMenuItemsByTypeInputs (1): a string representing a type of menu item (will be one of the four types listed in MENU_ITEM_TYPES) Return value: an integer representing the number of MenuItems of the input type o You do not need to define any getters and setters for this class. . At this point, you should be able to test the methods in the Menu class

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

Students also viewed these Programming questions