Question: 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

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.
Instance method
There are two instance method:
purchase
This method takes a list of items to be purchase. It calculates the total price of the purchase by
processing each item in the argument as show below:
The price of an item is obtained from the price list. If it is not found in the price list then the
default price is used. [How to determine if an item in not in the dict]
If the item is in the sales list then a discount is applied to the price
n.k.p Winter 2022 Page
Mark
3 Marks
4 Mark
Mark
Mark
Networking for Software Developers Classes Week03_Lab02
The item as well as the result price is added to the list as a tuple. [How to create a tuple with
name and price and how to add the tuple to the list]
When all the items are processed, if the final cost is over the credit threshold, then a
discount is applied to this amount and then subtracted from the amount of money this
object has left over.
__str__
This method returns a string representing this object i.e. the name, cash and all its purchases
pertaining to this shopper

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!