Commit 457306d0 by BellCodeEditor

save project

parent 36a2828a
Showing with 12 additions and 8 deletions
class Hero:
def __init__(self,name,hp,attack):
self.name='亚瑟'
self.name=name
self.level = 1
self.hp= 1000
self.attack= 100
self.name='后羿'
self.level = 1
self.hp= 995
self.attack= 150
self.hp= hp
self.attack= attack
yase = Hero('亚瑟',1000,100)
houyi = Hero('后羿',995,150)
......@@ -18,6 +13,15 @@ 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)
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