Commit 501958bb by BellCodeEditor

save project

parent 00097f6d
Showing with 36 additions and 19 deletions
class Dog: # 狗类
def __init__(self):
self.footNum = 4 # 腿
self.eyeNum = 2 # 眼睛
self.head = 1 # 头
self.earsNum = 2 # 耳朵
self.skin = "white"
def run(self):
print("狗狗飞快的跑起来")
class Husky(Dog): # 哈士奇类
def __init__(self):
??
coco = Husky()
print(coco.skin)
\ No newline at end of file
class Hero(object):
def __init__(self,name):
self.level=1
self.hp=3500
self.attack=388
self.name=name
def upgarde(self):
self.level+=1
self.hp+=50
self.attack+=4
def combat(self,enemy):
enemy.hp-=self.attack
inof1=self.name+'对'+enemy.name+'发起进攻'
inof2='造成'+str(self.attack)+'点伤害'
if enemy.hp>0:
inof3=enemy.name+'还剩下'+str(enemy.hp)+'血量'
inof=inof1+inof2+inof3
print(inof)
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