Advertisement
182days

OOP & Class 2

Apr 25th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.84 KB | None | 0 0
  1. #example 2 of using oop methods in programming
  2. #uses product class to create a list of products
  3. import time
  4.  
  5. class Product:
  6.     'base class for all new products'
  7.     productCount = 0
  8.  
  9.     def __init__(self, name, description, tradep, retailp):
  10.         self.name = name
  11.         self.description = description
  12.         self.tradep = tradeprice
  13.         self.retailp = retailprice
  14.         Product.productCount +=1
  15.  
  16.     def displayCount(self):
  17.         print("Total products %d" % Product.productCount)
  18.  
  19.     def displayName(self):
  20.         print("Product name : ", self.name)
  21.  
  22.     def displayDescription(self):
  23.         print("Product description : ", self.description)
  24.  
  25.     def displayTradep(self):
  26.         print("Product trade price : ", self.tradep)
  27.  
  28.     def displayRetailp(self):
  29.         print("Product retail price : ", self.retailp)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement