Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PYTHON : Mostly need Help with the Class LemonadeStand Write code for recording the menu items and daily sales of a stand. It will have

PYTHON : Mostly need Help with the Class LemonadeStand

Write code for recording the menu items and daily sales of a stand. It will have these classes: MenuItem, SalesForDay, and LemonadeStand. All data members of each class should be marked as private. Since they're private, if you need to access them from outside the class, you should do so via get or set methods.

Here are the method descriptions for the three classes:

MenuItem:

A MenuItem object represents a menu item to be offered for sale at the lemonade stand.

  • init method - takes as parameters three values with which to initialize the MenuItem: its name, its wholesale cost, and its selling price
  • get methods for each of the data members: get_name(), get_wholesale_cost(), and get_selling_price()
  • class MenuItem: def __init__(self, name_item, cost, price): self._name_item = name_item self._cost = cost self._price = price def get_name(self): return self._name_item def get_wholesale_cost(self): return self._cost def get_selling_price(self): return self._price

SalesForDay:

A SalesForDay object represents the sales for a particular day.

  • init method - takes as parameters two values with which to initialize the SalesForDay: the day (an integer for the number of days the stand has been open so far), and a dictionary whose keys are the names of the items sold, and whose values are the numbers of those items sold that day
  • get methods for each of the data members: get_day() and get_sales_dictionary()
class SalesForDay: def __init__(self, day, sales_dictionary): self._day = day self._sales_dictionary = sales_dictionary def get_day(self): return self._day def get_sales_dictionary(self): return self._sales_dictionary

LemonadeStand: Remember that the LemonadeStand class must not directly access the private data members of MenuItem and SalesForDay objects, but instead must call the appropriate get methods

A LemonadeStand 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 Lemonade 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 (remember to not use any mutable default arguments)
def __init__(self, name): self._name = name self._current_day = 0 self._items_dictionary = {} self._sale_record = []
  • 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

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

Demystifying Databases A Hands On Guide For Database Management

Authors: Shiva Sukula

1st Edition

8170005345, 978-8170005346

More Books

Students also viewed these Databases questions

Question

2. How much time should be allocated to the focus group?

Answered: 1 week ago

Question

1. Where will you recommend that she hold the focus group?

Answered: 1 week ago