Im not more than a beginner in python but here’s some of it (as i think it should be tabbed) if something is wrong someone else can hopefully point that out.
class Site(object):
#Defines the __init__ method, makes you Site object be
able to take in a few arguments
#Default values are set if non are supplied
def __init__(self, SiteNum="0", SiteAddr="", SiteInv=0):
#Sets the ID and Addr to submitted values
self.ID=SiteNum
self.Addr=SiteAddr
#Sets the private variable __Inv to the supplied value of SiteInv converting it to int
self.__Inv=int(SiteInv)
#Method that returns private var __Inv
def getInv(self):
return self.__Inv
#Method used to set the private var __Inv, takes the argument items
def setInv(self, items):
#Sets the variable
self.__Inv=int(items)
#Sets the property attribute, insteed of using x.getInv(), you can use x.getInv
#http://docs.python.org/library/functions.html#property
Inventory=property(getInv, setInv)
#Class ´´Store´´ which extends ´´Site´´
class Store(Site):
def Sale(self, items):
itemCnt=int(items)
self.Inventory -= itemCnt
#Class ´´Whse´´ which extends ´´Site´´
class Whse(Site):
def Recv(self, items):
itemCnt=int(items)
self.Inventory += itemCnt
#Creates a new Store object taking i initial values
store1=Store(SiteNum="001", SiteAddr="456 Elm St", SiteInv=1000)
wh1=Whse(SiteNum="002", SiteAddr="789 Maple St", SiteInv=20000)