Question: I need a python code. Write a class called Shopping Cart that might be used in an online store. It should have the following: A

I need a python code.
Write a class called Shopping Cart that might be used in an online store. It should have the following: A list of Item objects that represents the items in the shopping cart A constructor that creates an empty list of items (the constructor should take no arguments except self) A method called add() that takes a name and a price and adds an Item object with that name and price to the shopping cart A method called total() that takes no arguments and returns the total cost of the items in the cart A method called remove_items() that takes an item name (a string) and removes any Item objects with that name from the shopping cart. It shouldn't return anything. A str_() method that returns a string containing info on all the items in the shopping cart Then test out the shopping cart as follows: (1) create a shopping cart called mycart. (2) add several items to it; (3) print the cart's total cost (using the total() method); (4) remove one of the items types; (5) print out the cart
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
