Commit 08570667 by BellCodeEditor

save project

parent 0887446a
Showing with 8 additions and 6 deletions
...@@ -4,14 +4,16 @@ class hero: ...@@ -4,14 +4,16 @@ class hero:
self.name=name self.name=name
self.hp=hp self.hp=hp
self.attack=attack self.attack=attack
def upgrade(self):
self.level+=1
self.hp+=20
self.attack+=10
zhouyu=hero('周瑜',240,30) zhouyu=hero('周瑜',240,30)
zhangfei=hero('张飞',300,40) zhangfei=hero('张飞',300,40)
def upgrade(): zhouyu.upgrade()
zhouyu.level+=1 zhangfei.upgrade()
zhouyu.hp+=20
zhouyu.attack+=10
upgrade()
print(zhouyu.name) print(zhouyu.name)
print(zhouyu.hp) print(zhouyu.hp)
print(zhouyu.attack) print(zhouyu.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