Question: Python 3: Goal: Using the classes MenuItem & SalesOfDay (already created below), create another class Stand based on the instructions below. A Stand object represents
Python 3:
Goal: Using the classes MenuItem & SalesOfDay (already created below), create another class Stand based on the instructions below.
A Stand object represents a lemonade stand, which has four data members:
- a string for the name of the stand
- an integer representing the current day
- a dictionary of MenuItem objects, where the keys are the names of the items and the values are the corresponding MenuItem objects
- a list of SalesForDay objects
The Stand methods are:
- init method - takes as a parameter the name of the stand; initializes the name to that value, initializes current day to zero, initializes the menu to an empty dictionary, and initializes the sales record to an empty list
- a get method for the name: get_name()
- add_menu_item - takes as a parameter a MenuItem object and adds it to the menu dictionary
- enter_sales_for_today - takes as a parameter a dictionary where the keys are names of items sold and the corresponding values are how many of the item were sold. If the name of any item sold doesn't match the name of any MenuItem in the menu, it raises an InvalidSalesItemError (you'll need to define this exception class). Otherwise, it creates a new SalesForDay object, using the current day and the dictionary that was passed in, and then increments the current day by 1
- get_sales_dict_for_day - takes as a parameter an integer representing a particular day, and returns the dictionary of sales for that day (not a SalesForDay object)
- total_sales_for_menu_item - takes as a parameter the name of a menu item and returns the total number of that item sold over the history of the stand
- total_profit_for_menu_item - takes as a parameter the name of a menu item and returns the total profit on that item over the history of the stand
- total_profit_for_stand - takes no parameters and returns the total profit on all items sold over the history of the stand
class MenuItem: def __init__(self, stand_name, wholesale_cost, selling_price): self._stand_name = stand_name #Name of the stand self._wholesale_cost = wholesale_cost self._selling_price = selling_price def get_name(self): """"name of the menu item""" return self._name def get_wholesale_cost(self): """wholesale cost of the menu item""" return self._wholesale_cost
def get_selling_price(self): return self._selling_price
class SalesForDay: def __init__(self, day_open, sales_dict): self._day_open = day # integer for the number of days the stand has been open so far self._sales_dict = sales_dict #whose keys are the names of the items sold, and whose values are the numbers of those items sold that day def get_day(self): return self._day_open def get_sales_dict(self): return self._sales_dict
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
