Question: can someone please help me? it has to be in python. Design a class called ItemToPurchase . This class has the following attributes: item_name ,

can someone please help me? it has to be in python.

Design a class called ItemToPurchase. This class has the following attributes: item_name, item_price, and item_quanity; and has methods for checking the current value of each attribute, a method set_quantity for updating item_quantity value, and a method get_item_cost to return the cost of this item (calculating the product of item_price and item_quantity)

Design a function called take_item for creating an object of ItemToPurchase and returning the created object.

The main function defines a list of ItemToPurchase objects called shopping_cart and then calls the function take_item in a for loop to add multiple items to the shopping_cart list. The main function calls a function show_cart to display all the items in the shopping_cart list, and then calls a function update_cart to update the quantity for an item in the shopping_cart (the item is identified by its item_name attribute). The main function calls a function check_out to calculate and display to total charge for all the items in the shopping_cart.

The following is a sample output from this program.

How many item to take? 3 Add Item # 1 Item Name: Coffee Item Price: 2.5 Item Quantity: 4 Add Item # 2 Item Name: Chip Item Price: 1.25 Item Quantity: 6 Add Item # 3 Item Name: Milk Item Price: 3.75 Item Quantity: 2 Items in the Shopping Cart: 4 Coffee $ 2.5 each 6 Chip $ 1.25 each 2 Milk $ 3.75 each Item for Update: Milk New Quantity: 3 Items in the Shopping Cart: 4 Coffee $ 2.5 each 6 Chip $ 1.25 each 3 Milk $ 3.75 each Check Out Total Charge: $28.75

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!