本文整理汇总了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())+"."