Commit 6801a58d by BellCodeEditor

save project

parent 90ce8f01
Showing with 33 additions and 21 deletions
class Dog: # 狗类 class Hero:
def __init__(self): def __init__(self,name):
self.footNum = 4 # 腿 self.level=1
self.eyeNum = 2 # 眼睛 self.hp=250
self.head = 1 # 头 self.attack=40
self.earsNum = 2 # 耳朵 self.name=name
self.skin = "white" def combat(self,enemy):
enemy.hp-=self.attack
def run(self): a1=self.name+"对"+enemy.name+"发动了攻击,"
print("狗狗飞快的跑起来") a2="造成了"+str(self.attack)+"点伤害,"
if enemy.hp>0:
a3=enemy.name+"剩余"+str(enemy.hp)+"点血量"
class Husky(Dog): # 哈士奇类 a=a1+a2+a3
def __init__(self): print(a)
super().__init__() else:
self.skin = "black" a3=enemy.name+"阵亡,游戏结束"
a=a1+a2+a3
print(a)
coco = Husky() exit()
print(coco.skin)
\ No newline at end of file class player(Hero):
def __init__(self,name,here_type):
super().__init__(name)
self.hp=200
self.attack=250
self.hero_type=here_type
print("角色"+self.name+"创建成功,英雄类型为:"+self.hero_type)
print("当前等级、血量、攻击力分别为:"+str(self.level)+"、"+str(self.hp)+"、"+str(self.attack))
saisai = Hero("赛赛")
wuhao=player("吴昊","小兵")
wuhao.combat(saisai)
\ 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