Commit fa91dcc7 by BellCodeEditor

auto save

parent 9a581ef4
Showing with 21 additions and 14 deletions
# 英雄角色类 class hero:
class Hero(object): def __init__(self,name,level,hp,attack):
def __init__(self, name): self.level=level
self.level = 1 self.hp=hp
self.hp = 250 self.attack=attack
self.attack = 40 self.name=name
self.name = name LuBan=hero('鲁班',1,2500,230)
HouYi=hero('后羿',1,3000,180)
def combat(): # 攻击 def combat(self):
???
yase = Hero("垭瑟") print(LuBan.name)
houyi= Hero("后羿") print(LuBan.level)
yase.combat(houyi) print(LuBan.hp)
\ No newline at end of file print(LuBan.attack)
print(LuBan.name)
print(LuBan.level)
print(LuBan.hp)
print(LuBan.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