Commit a3dfcb92 by BellCodeEditor

auto save

parent 457306d0
Showing with 11 additions and 19 deletions
class Hero: class Hero:
def __init__(self,name,hp,attack): def __init__(self,name,hp,attack):
self.name=name self.level = 1
self.name = name
self.level = 1 self.level = 1
self.hp= hp self.hp= hp
self.attack= attack self.attack= attack
yase = Hero('亚瑟',1000,100) def upgrade(self):
houyi = Hero('后羿',995,150) self.level=self.level+1
self.hp = self.hp + 100
print("yase的血量值为:",yase.hp) self.attack = self.attack + 10
print("yase的攻击力为:",yase.attack)
print("houyi的血量值为:",houyi.hp)
print("houyi的攻击力为:",houyi.attack)
def upgrade():
yase.level=yase.level+1
yase.hp=yase.hp+100
yase.attack=yase.attack+10
yase = Hero('亚瑟',1000,100)
print("亚瑟的初始血量值为:",yase.hp)
upgrade()
upgrade()
print("升级2次后,亚瑟的血量值为:",yase.hp)
houyi = Hero('后羿',995,150)
houyi.upgrade()
print("等级为:",houyi.level)
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