Commit d1b1c6eb by BellCodeEditor

save project

parent 2025e374
Showing with 27 additions and 16 deletions
class Dog: class Hero:
def __init__(self): def __init__(self,name):
self.footNum = 4 self.level = 1
self.eyeNum = 2 self.hp = 240
self.head = 1 self.attack = 40
self.earNum = 2 self.name = name
self.skin = "white" def combat(self, enemy):
def run(self): info1 = self.name+"对"+enemy.name+"发起进攻,"
print("狗狗飞快的跑起来") info2 = "造成"+str(self.attack)+"点伤害,"
class Husky(Dog): enemy.hp -= self.attack
def __init__(self): if enemy.hp > 0:
super(). __init__() info3 = enemy.name+"还剩下"+str(enemy.hp)+"血量"
self.skin = "black" info = info1=info2+info3
coco = Husky() print(info)
print(coco.skin) exit()
\ No newline at end of file class Player(Hero):
def __init__(self,name,hero_type):
self(Player,self).__init__(name)
self.hp = 200
self.attack = 50
self.hero_type = hero_type
print("角色"+self.name+"创造成功,英雄类型为:",self.hero_type)
print("当前等级血量、攻击力为:",self.level,self.hp,self.attack)
houyi = Player("后一","射手")
yase = Hero("垭瑟")
\ 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