Skip to content

Instantly share code, notes, and snippets.

@dag10
Forked from blackcorvidae/Product.py
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dag10/e755567701c76935cdab to your computer and use it in GitHub Desktop.
Save dag10/e755567701c76935cdab to your computer and use it in GitHub Desktop.
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()
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
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