Commit e47352e9 by BellCodeEditor

save project

parent c7e3a89d
Showing with 9 additions and 16 deletions
......@@ -4,19 +4,13 @@ class Hero():
self.name=name
self.hp = hp
self.attack = attack
sb=Hero("孙悟空",1000,100)
bigsb=Hero("韩信",1000,99)
biggersb=Hero("李白",999,100)
print("孙悟空的血量为:",sb.hp)
print("韩信的血量为:",bigsb.hp)
print("李白的血量为:",biggersb.hp)
def upgrade():
sb.level = sb.level+1
sb.hp = sb.hp+100
sb.attack = sb.attack+50
upgrade()
upgrade()
upgrade()
upgrade()
upgrade()
\ No newline at end of file
def upgrade(self):
self.level = self.level+1
self.hp = self.hp+100
self.attack = self.attack+50
sb=Hero("孙悟空",1000,100)
sb.upgrad()
print("等级为:",sb.level)
print("血量为:",sb.hp)
print("攻击力为:",sb.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