-
-
Save dag10/e755567701c76935cdab to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from Product import Product | |
from Store import Store | |
store = Store() | |
store.addProduct(Product('Toaster', 'It toasts things.')) | |
store.addProduct(Product('Oven', 'It bakes things.')) | |
for product in store.getProducts(): | |
print product.profile() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Product: | |
name = "Product Name" | |
description = "Product Description" | |
price = 0 | |
def __init__(self, name, description): | |
self.name = name | |
self.description = description | |
def setPrice(self, price): | |
self.price = price | |
def getPrice(self): | |
return self.price | |
def profile(self): | |
return self.name + "\n" + self.description | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Store: | |
name = "Store Name" | |
description = "Store Description" | |
products = [] | |
def __init__(self): | |
pass | |
def profile(self): | |
return self.name + "\n" + self.description | |
def addProduct(self, product): | |
self.products.append(product) | |
def getProducts(self): | |
return self.products | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment