Commit 4e9fcbe6 by BellCodeEditor

save project

parent d9106f73
Showing with 9 additions and 7 deletions
class Hero:
def __init__(self,name,hp,attack):
def __init__(self,name,hp,attack): #定义角色的属性
self.level=1
self.name=name
self.hp=hp
self.attack=attack
def uplevel(self):
def uplevel(self): #定义角色升级时属性的提升数值
self.level=self.level+1
self.hp=self.hp+50
self.attack=self.attack+4
yase=Hero("亚瑟",300,20)
houyi=Hero('后羿',250,23)
gl=Hero("小明",300,20) #定义英雄
hb=Hero('小东',250,23)
yase.uplevel()
print(yase.hp)
\ No newline at end of file
gl.uplevel()
print(gl.name) #显示各数值
print(gl.hp)
print(gl.attack)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment