Commit 501958bb by BellCodeEditor

save project

parent 00097f6d
Showing with 36 additions and 19 deletions
class Dog: # 狗类 class Hero(object):
def __init__(self): def __init__(self,name):
self.footNum = 4 # 腿 self.level=1
self.eyeNum = 2 # 眼睛 self.hp=3500
self.head = 1 # 头 self.attack=388
self.earsNum = 2 # 耳朵 self.name=name
self.skin = "white" def upgarde(self):
self.level+=1
def run(self): self.hp+=50
print("狗狗飞快的跑起来") self.attack+=4
def combat(self,enemy):
enemy.hp-=self.attack
class Husky(Dog): # 哈士奇类 inof1=self.name+'对'+enemy.name+'发起进攻'
def __init__(self): inof2='造成'+str(self.attack)+'点伤害'
?? if enemy.hp>0:
inof3=enemy.name+'还剩下'+str(enemy.hp)+'血量'
coco = Husky() inof=inof1+inof2+inof3
print(coco.skin) print(inof)
\ No newline at end of file else:
inof3=enemy.name+'已阵亡'
inof=inof1+inof2+inof3
print(inof)
exit()
class Player(Hero):
def __init__(self,name):
super().__init__(name)
self.hp=200
self.attack=50
player=Player('后羿')
print('玩家的血量为:',player.hp)
print('玩家的攻击为:',player.attack)
yase=Hero('亚瑟')
houyi=Hero('后羿','射手')
print('角色'+houyi.name+'创建成功,英雄类型为:',houyi.hero_type)
print('当前等级、血量、攻击力分别为:',houyi.level,houyi.hp,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