class Prod:
def __init__(self, cName, iId, dPrice, iNo, cSupp):
self.cName = cName
self.iId = iId
self.dPrice = dPrice
self.iNo = iNo
self.cSupp = cSupp
def println(self):
print self.cName + "\t ",
print str(self.iId) + "\t ",
print str(self.dPrice) + "\t ",
print str(self.iNo) + "\t ",
print self.cSupp + "\t\n",
if __name__ == '__main__':
prodOne = Prod("Olive Oil",1001,120.50,250,"Frescati Oil S/A")
print "Enter information for product"
cName = raw_input("Start with the product name: ")
iId = int(raw_input("The product id: "))
dPrice = float(raw_input("The price: "))
iNo = int(raw_input("How many items are there in stock: "))
cSupp = raw_input("Who supplies the product: ")
prodTwo = Prod(cName,iId,dPrice,iNo,cSupp)
print "Productname \t Product id \t Price \t Quantity \t Supplier\n"
prodOne.println()
prodTwo.println()
class Prod:
def __init__(self, cName, iId, dPrice, iNo, cSupp):
self.cName = cName
self.iId = iId
self.dPrice = dPrice
self.iNo = iNo
self.cSupp = cSupp
def printOnScreen(prodOne1):
print prodOne1.cName + "\t ",
print str(prodOne1.iId) + "\t ",
print str(prodOne1.dPrice) + "\t ",
print str(prodOne1.iNo) + "\t ",
print prodOne1.cSupp + "\t\n",
if __name__ == '__main__':
prodOne = Prod("Olive Oil",1001,120.50,250,"Frescati Oil S/A")
printOnScreen(prodOne)
class Prod:
def __init__(self, cName, iId, dPrice, iNo, cSupp):
self.cName = cName
self.iId = iId
self.dPrice = dPrice
self.iNo = iNo
self.cSupp = cSupp
def printOnScreen(p,n):
for i in range(n):
print p[i].cName + "\t ",
print str(p[i].iId) + "\t ",
print str(p[i].dPrice) + "\t ",
print str(p[i].iNo) + "\t ",
print p[i].cSupp + "\t\n",
if __name__ == '__main__':
sProds = []
sProds.append(Prod("Food Oil",101,12.50,100,"Felix Ltd"))
sProds.append(Prod("Baby Oil",102,23.75,25,"Baby Prod"))
sProds.append(Prod("Boiler Oil",103,6100,123000,"Shell"))
printOnScreen(sProds,3)
class Prod:
def __init__(self, cName, iId, dPrice, iNo, cSupp):
self.cName = cName
self.iId = iId
self.dPrice = dPrice
self.iNo = iNo
self.cSupp = cSupp
def printOnScreen(p,n):
for i in range(n):
print p[i].cName + "\t ",
print str(p[i].iId) + "\t ",
print str(p[i].dPrice) + "\t ",
print str(p[i].iNo) + "\t ",
print p[i].cSupp + "\t\n",
if __name__ == '__main__':
sProds = []
sProds.append(Prod("Food Oil",101,12.50,100,"Felix Ltd"))
sProds.append(Prod("Baby Oil",102,23.75,25,"Baby Prod"))
sProds.append(Prod("Boiler Oil",103,6100,123000,"Shell"))
pProds = id(sProds)
printOnScreen(sProds,3)