Commit 6791d25f by BellCodeEditor

save project

parent 912af26a
Showing with 38 additions and 0 deletions
class Hero:
def __init__(self,name,hp,attack):
self.level = 1
self.name = name
self.hp = hp
self.attack = attack
def upgrade(self):
self.level = self.level + 1
self.hp = self.hp + 50
self.attack = self.attack + 4
# 亚瑟 = Hero()
# print(亚瑟.level)
# print(亚瑟.attack)
yase = Hero("亚瑟",400,20)
houyi = Hero("后羿",200,50)
# print("英雄:" + yase.name + " 攻击力:" + str(yase.attack))
# print("英雄:" + houyi.name + " 攻击力:" + str(houyi.attack))
# def upy():
# yase.level = yase.level + 1
# yase.hp = yase.hp + 50
# yase.attack = yase.attack + 4
# def uph():
# houyi.level = houyi.level + 1
# houyi.hp = houyi.hp + 50
# houyi.attack = houyi.attack + 4
# upy()
# uph()
yase.upgrade()
houyi.upgrade()
print("英雄:" + yase.name + " 攻击力:" + str(yase.attack))
print("英雄:" + houyi.name + " 攻击力:" + str(houyi.attack))
\ No newline at end of file
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