Commit 7b4250fe by BellCodeEditor

auto save

parent 1cf9f5c8
Showing with 37 additions and 1 deletions
#第一节
class Hero(object):
def __init__(self, name):
self.level = 1
self.hp = 250
self.attack = 40
self.name = name
def combat(self,gjdx): # 攻击
gjdx.hp-=self.attack
info1=self.name+'对'+gjdx.name+'发起攻击'
info2=gjdx.name+'血量减少'+str(self.attack)
if gjdx.hp>0:
info3=gjdx.name+'的血量还剩'+str(gjdx.hp)
info=info1+info2+info3
print(info)
else:
info3=gjdx.name+'血量不足,已阵亡,游戏结束'
info=info1+info2+info3
print(into)
exit()
#第二节
class Player(Hero):
def __init__(self,name,leixing):
super(Player,self).__init__(name)
self.hp=200
self.attack=50
self.leixing=leixing
print(self.name+'已创建')
print(self.name+'是一名'+self.leixing)
print(self.name+'的初始血量为:'+str(self.hp),';'+'初始攻击为:'+str(self.attack))
yase = Hero("垭瑟")
houyi= Player("后羿",'弓箭手')
yase.combat(houyi)
...@@ -12,7 +12,8 @@ class Dog: # 狗类 ...@@ -12,7 +12,8 @@ class Dog: # 狗类
class Husky(Dog): # 哈士奇类 class Husky(Dog): # 哈士奇类
def __init__(self): def __init__(self):
?? super().__init__()
self.skin='black'
coco = Husky() coco = Husky()
print(coco.skin) print(coco.skin)
\ 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