本文整理匯總了Python中Class.getDescr方法的典型用法代碼示例。如果您正苦於以下問題:Python Class.getDescr方法的具體用法?Python Class.getDescr怎麽用?Python Class.getDescr使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Class
的用法示例。
在下文中一共展示了Class.getDescr方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: character
# 需要導入模塊: import Class [as 別名]
# 或者: from Class import getDescr [as 別名]
class character(object):
'''
Represents a Character with a race and a class
'''
def __init__(self,charName,charRace,charClass):
'''
Creates the char and adopts race and class from
the other objects
'''
self.charName=charName
self.charRace=race(charRace)
self.charClass=Class(charClass)
self.charDescr=""
def getName(self):
'''
Returns Character's Name
'''
return self.charName
def getRace(self):
'''
Returns Character's Race
'''
return self.charRace.getName()
def getClass(self):
'''
Returns Character's Class
'''
return self.charClass.getName()
def setCharDescr(self,charDescr):
'''
Sets Characters Description
'''
assert type(charDescr)==str, "Description must be a string"
if self.charDescr=="":
self.charDescr=charDescr
else:
print "There is already a Character Descriptio use the update method"
def updateCharDescr(self,charDescr):
'''
Updates Character's Name
'''
assert type(charDescr)==str, "StoryLine must be A string"
self.charDescr=charDescr
def getCharDescr(self):
return self.charDescr
def getRaceStory(self):
return self.charRace.getStory()
def getClassDescr(self):
return self.charClass.getDescr()
def __str__(self):
return str(self.getName())+" "+"is a"+" "+str(self.getRace())+" "+str(self.getClass())+"."