Commit 7bdd0413 by BellCodeEditor

save project

parent 22354288
Showing with 27 additions and 0 deletions
class hero():
def __init__(self,name,hp,attack):
self.level = 1
self.name = name
self.hp = hp
self.attack = attack
def upgrade(self):
print("英雄升级了,属性增加了")
self.level += 1
self.hp += 50
self.attack += 5
def look(name):
print("角色:"+str(name.name))
print("等级:"+str(name.level))
print("血量:"+str(name.hp))
print("攻击力:"+str(name.attack))
yase = hero("亚瑟",300,20)
houyi = hero("后羿",250,23)
houyi.upgrade()
look(houyi)
look(yase)
\ 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