Commit 5b82e7ad by BellCodeEditor

save project

parent 354335ee
Showing with 9 additions and 21 deletions
class Hero: class Hero:
def __init__(self, name, hp, attack): def __init__(self):
self.level=1 self.level = 1
self.name = name self.hp= 300
self.hp= hp self.attack= 20
self.attack= attack
def unpgrade(): yase = Hero()
self.level=yase.level+1 print("yase的血量值为:",yase.hp)
self.hp=yase.hp+50 print("yase的攻击力为:",yase.attack)
self.attack=yase.attack+4 \ No newline at end of file
houyi = Hero("后羿",240,23)
houyi.unpgrade()
print("等级:",houyi.)
print("血量:",houyi.hp)
print("攻击力:",houyi.attack)
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