class ShoppingCart:
def __init__(self):
self.cart = []
def add_item(self, item):
""" (ShoppingCart, Item) -> NoneType
Adds an item to the cart.
"""
self.cart.append(item)
def show_cheapest_item(self):
""" (ShoppingCart) -> int
Return the cheapest item in the cart, or -1 if no items are in the cart
"""
# my point of confusion
class Item:
""" An instance of an item """
def __init__(self, price):
""" (Item, float)
Initialize an Item
"""
self.price = price
我想在车返回最廉价的物品内发现的最低值,我无法访问任何方式价目表。实例变量
请后两类 – alfasin 2014-11-23 22:46:34