Commit e47352e9 by BellCodeEditor

save project

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