Commit a6949547 by BellCodeEditor

save project

parent 22354288
Showing with 23 additions and 0 deletions
class Hero:
def __init__(self,name,level,hp,attack):
self.level=1
self.name=name
self.hp=hp
self.attack=attack
def levellift(self):
self.level = self.level+1
self.hp=self.hp+500
self.attack=self.attack+200
houyi=Hero('后羿',1,2000,100)
print(houyi.name+"升级后属性:依次为等级、血量、攻击力")
print(houyi.level)
print(houyi.hp)
print(houyi.attack)
# houyi=Hero('后羿',2000,100)
# houyi.level=2
# houyi.hp=3000
# houyi.attack=300
# print("英雄"+str(houyi.name))
# print("等级"+str(houyi.level))
# print("血量"+str(houyi.hp))
# print("攻击力"+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