Commit 2876e867 by BellCodeEditor

save project

parent 6db6211e
Showing with 21 additions and 3 deletions
import time
class Hero:
def __init__(self,name,hp,attack):
self.level = 1
self.name = name
self.hp = hp
self.attack = attack
yase = Hero('亚瑟',400,50)
print(yase.name+':'+str(yase.hp)+str(yase.attack))
\ No newline at end of file
def upgrade():
yase.level+=1
yase.hp*=2
yase.attack*=2
yase=Hero("亚瑟",400,50)
print(yase.name+"等级为"+str(yase.level))
print(yase.name+"血量为"+str(yase.hp))
print(yase.name+"攻击为"+str(yase.attack))
time.sleep(1)
upgrade()
print(yase.name+"等级为"+str(yase.level))
print(yase.name+"血量为"+str(yase.hp))
print(yase.name+"攻击为"+str(yase.attack))
time.sleep(1)
upgrade()
print(yase.name+"等级为"+str(yase.level))
print(yase.name+"血量为"+str(yase.hp))
print(yase.name+"攻击为"+str(yase.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