Commit c56192c6 by BellCodeEditor

save project

parent ad8d31ce
Showing with 11 additions and 1 deletions
...@@ -4,10 +4,19 @@ class Hero: ...@@ -4,10 +4,19 @@ class Hero:
self.name=name self.name=name
self.hp=hp self.hp=hp
self.attack=attack self.attack=attack
def qwerk(self):
self.level=self.level+1
self.hp=self.hp+50
self.attack=self.attack+4
lujuren=Hero("绿巨人",100,20) lujuren=Hero("绿巨人",100,20)
libai=Hero("李白",80,30) libai=Hero("李白",80,30)
meiguoduizhang=Hero("美国队长",105,25) meiguoduizhang=Hero("美国队长",105,25)
lujuren.qwerk()
libai.qwerk()
meiguoduizhang.qwerk()
print("绿巨人的血量:",lujuren.hp) print("绿巨人的血量:",lujuren.hp)
print("绿巨人的攻击力:",lujuren.attack)
print("李白的血量:",libai.hp) print("李白的血量:",libai.hp)
print("李白的攻击力:",libai.attack)
print("美国队长的血量:",meiguoduizhang.hp)
print("美国队长的攻击力:",meiguoduizhang.attack) print("美国队长的攻击力:",meiguoduizhang.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