Commit c8163904 by BellCodeEditor

save project

parent 49e7b569
Showing with 14 additions and 4 deletions
# 英雄角色类 # 英雄角色类
class Hero(object): class Hero(object):
def __init__(self, name): def __init__(self, name):
self.level = -1 self.level = 1
self.hp = -10 self.hp = 200
self.attack = -999999999999999999999999999999999999999999999999999999999999999 self.attack = 9
self.name = name self.name = name
def combat(self,enemy): # 攻击 def combat(self,enemy): # 攻击
...@@ -18,7 +18,16 @@ class Hero(object): ...@@ -18,7 +18,16 @@ class Hero(object):
info3=enemy.name+"死了,game over" info3=enemy.name+"死了,game over"
info=info1+info2+info3 info=info1+info2+info3
print(info) print(info)
exit()
class player(Hero):
def __init__(self,name,Hero_type):
super().__init__(name)
self.hp=100
self.attack=10
self.Hero_type=Hero_type
print("角色"+self.name+"创建成功,英雄类型为:",self.Hero_type)
print("当前等级、血量、攻鸡力分别是:",self.level,self.hp,self.attack)
yase = Hero("垭瑟") yase = Hero("垭瑟")
houyi= Hero("后羿") houyi= player("后羿","坦克")
yase.combat(houyi) yase.combat(houyi)
\ 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