Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Description of the Shopper Class Class variable There are six class variables i . e . variables that are shared by all objects of this

Description of the Shopper Class
Class variable
There are six class variables i.e. variables that are shared by all objects of this class
__prices
This is a python dict that contains the grocery items as well as their unit price. This is defined as
follows:
__prices =
{ 'apple': 1.8, 'bread': 2.2, 'milk': 4.9, 'pepper': 1.2}
__sale_items
This is a list that contains all the items that are on sale in this period. A discount of 15% is applied
to the price of each item in this collection. This is defined as follows:
__sale_items = 'apple banana'.split()
Four other class variable that are define as follows:
__discount_threshold =6
When the total cost of a purchase exceeds this amount then a discount is applied to the cost
__default_price =2.50
If an item is not found in the __prices dictionary, then this will be the default price
Mark
Mark
Mark
Mark
Networking for Software Developers Classes Week03_Lab02
__volume_discount =0.9
This is the rate of discount when the total cost exceeds the discount_threshold
__sales_discount =0.85
This is the rate of discount on an item if this item is in the __sales_time list.
Constructor
The constructor takes two argument that represents the name of the shopper and the amount of
money she has. It assigns the argument to appropriate instance variable. It also creates an empty
list to store the purchases.
Each purchase is a single tuple comprising of the name of the item and the price actually paid for
the item.
Instance property
There is a single instance property that returns the name of this shopper object
Class method
There are three class methods:
1. One that returns the price list.
2. One that returns the list of sale items.
3. One that adds a new item to the sale items list

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

Logic In Databases International Workshop Lid 96 San Miniato Italy July 1 2 1996 Proceedings Lncs 1154

Authors: Dino Pedreschi ,Carlo Zaniolo

1st Edition

3540618147, 978-3540618140

More Books

Students also viewed these Databases questions