Commit ac98e1d2 by BellCodeEditor

save project

parent 22354288
Showing with 44 additions and 0 deletions
import time
class Hero():
def __init__(self,name,hp,attack):
self.level=1
self.name=name
self.hp=hp
self.attack=attack
def upgrade(self):
print(yase.name+'升级!!')
self.level+=1
self.hp+=50
self.attack+=5
yase=Hero('亚瑟',300,20)
print(yase.name,'的等级为',yase.level)
print(yase.name,'的血量为',yase.hp)
print(yase.name,'的攻击力为',yase.attack)
time.sleep(1)
yase.upgrade()
print(yase.name,'的等级为',yase.level)
print(yase.name,'的血量为',yase.hp)
print(yase.name,'的攻击力为',yase.attack)
time.sleep(1)
yase.upgrade()
print(yase.name,'的等级为',yase.level)
print(yase.name,'的血量为',yase.hp)
print(yase.name,'的攻击力为',yase.attack)
time.sleep(1)
houyi=Hero('侯毅',240,23)
print(houyi.name,'的等级为',houyi.level)
print(houyi.name,'的血量为',houyi.hp)
print(houyi.name,'的攻击力为',houyi.attack)
time.sleep(1)
houyi.upgrade()
print(houyi.name,'的等级为',houyi.level)
print(houyi.name,'的血量为',houyi.hp)
print(houyi.name,'的攻击力为',houyi.attack)
time.sleep(1)
houyi.upgrade()
print(houyi.name,'的等级为',houyi.level)
print(houyi.name,'的血量为',houyi.hp)
print(houyi.name,'的攻击力为',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