writing pseudocode or other language please complete the following to do items
Task #1
Programming:
Writing pseudocode or other language please complete the following To Do items.
Try your best to complete as much as you can. If you cannot come up with a solution try to outline how you would solve it.
Feel free to use Google or other resources but note that this is focusing on how you approach a problem and basic programming knowledge. This is not testing your knowledge of Python nor is anything designed to be misleading or tricky.
class Shopper:
def __init__(name):
self.name = name
self.cart = []
#TODO: Implement this!
def cart_add(item):
“””
Adds item to our cart
Parameters:
item (item object): An instance of the item class
Returns:
item (item object): The item that was added to the cart
“””
#TODO: Implement this
def print_cart():
“””
Prints the items in our cart like so:
Item Name – Quantity
“””
class Item():
def __init__(name, brand, price)
self.name = name
self.brand = brand
self.price = price
def get_price()
return self.price
-3-
def get_name()
return self.name
def get_brand()
return self.brand
#TODO: Implement This
def compare(): #TODO: Add Parameters
“””
Compares N Items choosing the cheaper one
Parameters:
???
Returns:
item_object: The Cheapest Item
“””
def main():
grocery_one = Item(“Super Mayo”, “Not An Instrument Grocery Co.”, 5.00)
grocery_two = Item(“Questionable Mayonnaise”, “Bob’s Bargain Basement Supply”, 3.50)
#TODO: Create a New Shopper for yourself
#TODO: Call the compare function and add the cheaper product to the cart!