Commit b4fe72ca by BellCodeEditor

save project

parent 96f5bea6
Showing with 16 additions and 5 deletions
# 英雄角色类 # 英雄角色类
class Hero(object): class Hero():
def __init__(self, name): def __init__(self, name):
self.level = 1 self.level = 1
self.hp = 250 self.hp = 250
self.attack = 40 self.attack = 40
self.name = name self.name = name
self.max_hp=self.hp
def combat(self,enemy): # 攻击 def combat(self,enemy): # 攻击
...@@ -20,6 +21,16 @@ class Hero(object): ...@@ -20,6 +21,16 @@ class Hero(object):
info = info1 + info2 + info3 info = info1 + info2 + info3
print(info) print(info)
exit() exit()
yase = Hero("满级老6")
houyi= Hero("卢本伟") class Player(Hero):
yase.combat(houyi) def __init__(self,name,hero_type):
\ No newline at end of file super(Player,self).__init__(name)
self.hp =200
self.attack=250
self.hero_type = hero_type
print("英雄"+self.name+"创建成功,类型为:"+self.hero_type)
print("当前等级,血量,攻击力分别为:",self.level,self.hp,self.attack)
sb = Player("sb","刺客")
\ 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