Commit b3577640 by BellCodeEditor

save project

parent e1fc2c13
Showing with 9 additions and 7 deletions
...@@ -5,15 +5,16 @@ class Hero(): ...@@ -5,15 +5,16 @@ class Hero():
self.hp=hp self.hp=hp
self.attack=attack self.attack=attack
def upgrade(self):
self.level += 1
self.hp += 50
self.attack += 4
yase = Hero('亚瑟',300,20) yase = Hero('亚瑟',300,20)
dunshan=Hero('盾山',500,10) dunshan=Hero('盾山',500,10)
def upgrade():
yase.level += 1
yase.hp += 50
yase.attack += 4
upgrade() dunshan.upgrade()
upgrade()
upgrade()
print('亚瑟的攻击力为:',yase.attack) print('亚瑟的攻击力为:',yase.attack)
print('盾山的血量为:',dunshan.hp) print('盾山的血量为:',dunshan.hp)
\ 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