Commit 7f4a4f33 by BellCodeEditor

save project

parent 2876e867
Showing with 20 additions and 6 deletions
...@@ -5,23 +5,37 @@ class Hero: ...@@ -5,23 +5,37 @@ class Hero:
self.name = name self.name = name
self.hp = hp self.hp = hp
self.attack = attack self.attack = attack
def upgrade(): def upgrade(self):
yase.level+=1 self.level+=1
yase.hp*=2 self.hp*=2
yase.attack*=2 self.attack*=2
yase=Hero("亚瑟",400,50) yase=Hero("亚瑟",400,50)
print(yase.name+"等级为"+str(yase.level)) print(yase.name+"等级为"+str(yase.level))
print(yase.name+"血量为"+str(yase.hp)) print(yase.name+"血量为"+str(yase.hp))
print(yase.name+"攻击为"+str(yase.attack)) print(yase.name+"攻击为"+str(yase.attack))
time.sleep(1) time.sleep(1)
upgrade() yase.upgrade()
print(yase.name+"等级为"+str(yase.level)) print(yase.name+"等级为"+str(yase.level))
print(yase.name+"血量为"+str(yase.hp)) print(yase.name+"血量为"+str(yase.hp))
print(yase.name+"攻击为"+str(yase.attack)) print(yase.name+"攻击为"+str(yase.attack))
time.sleep(1) time.sleep(1)
upgrade() yase.upgrade()
print(yase.name+"等级为"+str(yase.level)) print(yase.name+"等级为"+str(yase.level))
print(yase.name+"血量为"+str(yase.hp)) print(yase.name+"血量为"+str(yase.hp))
print(yase.name+"攻击为"+str(yase.attack)) print(yase.name+"攻击为"+str(yase.attack))
houyi=Hero("后羿",200,250)
print(houyi.name+"等级为"+str(houyi.level))
print(houyi.name+"血量为"+str(houyi.hp))
print(houyi.name+"攻击为"+str(houyi.attack))
time.sleep(1)
houyi.upgrade()
print(houyi.name+"等级为"+str(houyi.level))
print(houyi.name+"血量为"+str(houyi.hp))
print(houyi.name+"攻击为"+str(houyi.attack))
time.sleep(1)
houyi.upgrade()
print(houyi.name+"等级为"+str(houyi.level))
print(houyi.name+"血量为"+str(houyi.hp))
print(houyi.name+"攻击为"+str(houyi.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