Commit 0e747ca8 by BellCodeEditor

save project

parent 307701c1
Showing with 11 additions and 11 deletions
class Hero: class Hero:
def __init__(self,name,hp,attack): def __init__(self,name,hp,attack):
self.name=name
self.level=1 self.level=1
self.name=name
self.hp=hp self.hp=hp
self.attack=attack self.attack=attack
kai=Hero("kai",100,25) # kai=Hero("kai",100,30)
yase=Hero("yase",100,20) # yase=Hero("yase",90,20)
# print("kai的血量",kai.hp) # print("kai的血量",kai.hp)
# print("yase的攻击力",yase.attack) # print("yase的攻击力",yase.attack)
def upgrade(): def upgrade(self):
kai.level=kai.level+1 self.level=self.level+1
kai.hp=kai.hp+20 self.hp=self.hp+20
kai.attack=kai.attack+15 self.attack=self.attack+10
kai=Hero("kai",100,30)
upgrade() kai.upgrade()
upgrade() print("kai的血量为:",kai.hp)
print(kai.level) print("kai的攻击力为:",kai.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