Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #example 2 of using oop methods in programming
- #uses product class to create a list of products
- import time
- class Product:
- 'base class for all new products'
- productCount = 0
- def __init__(self, name, description, tradep, retailp):
- self.name = name
- self.description = description
- self.tradep = tradeprice
- self.retailp = retailprice
- Product.productCount +=1
- def displayCount(self):
- print("Total products %d" % Product.productCount)
- def displayName(self):
- print("Product name : ", self.name)
- def displayDescription(self):
- print("Product description : ", self.description)
- def displayTradep(self):
- print("Product trade price : ", self.tradep)
- def displayRetailp(self):
- print("Product retail price : ", self.retailp)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement