Commit 4a200eb8 by BellCodeEditor

save project

parent b01cfd75
Showing with 9 additions and 0 deletions
...@@ -4,7 +4,15 @@ class Hero: ...@@ -4,7 +4,15 @@ class Hero:
self.姓名=姓名 self.姓名=姓名
self.血量=血量 self.血量=血量
self.攻击力=攻击力 self.攻击力=攻击力
def 升级(self):
self.等级=self.等级+1
self.血量=self.血量+50
self.攻击力=self.攻击力+5
瑞雯=Hero("瑞雯",300,20) 瑞雯=Hero("瑞雯",300,20)
习景舒=Hero("习景舒",999,299) 习景舒=Hero("习景舒",999,299)
print("习景舒的攻击力为",习景舒.攻击力) print("习景舒的攻击力为",习景舒.攻击力)
print("瑞雯的攻击力为",瑞雯.攻击力) print("瑞雯的攻击力为",瑞雯.攻击力)
瑞雯.升级()
习景舒.升级()
print("习景舒的攻击力为",习景舒.攻击力)
print("瑞雯的攻击力为",瑞雯.攻击力)
\ 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