Commit b8dd448a by BellCodeEditor

save project

parent 3500667c
Showing with 12 additions and 7 deletions
class Heyo: class Heyo:
def __init__(self,name,hp,attack): def __init__(self,name,hp,attack):
self.level = 1
self.name=name self.name=name
self.hp=hp self.hp=hp
self.attack=attack self.attack=attack
yase = Heyo('垭瑟',300,20)
houyi = Heyo('后羿',250,25) def upgrade():
libai = Heyo('李白',350,15) yase.level=yase.level+1
print("垭瑟的血量为:",yase.hp) yase.hp=yase.hp+100
print("后羿的血量为:",houyi.hp) yase.attack=yase.attack+100
print("李白的血量为:",libai.hp)
\ No newline at end of file yase = Heyo("垭瑟",300,20)
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