Commit df53ee8b by BellCodeEditor

save project

parent a7a79e98
Showing with 33 additions and 13 deletions
class Dog:
class Hero:
def __init__(self):
self.footNum = 4
self.eyeNum = 2
self.head = 1
self.earsNum = 2
self.skin = "white"
def run(self):
print("狗狗飞快的跑起来")
self.lv = 0
self.hp = 0
self.att = 0
self.name = "默认英雄"
self.maxhp = self.hp
print("创建了一个默认英雄,他的血量是",self.hp)
class Husky(Dog):
def __init__(self):
def gongji(self,e):
e.hp -= self.att
print(self.name + "攻击" + e.name
+ "造成" + str(self.att) + "点伤害,"
+ e.name + "剩" + str(e.hp) + "点血。")
def cure(self):
self.hp += 50
if self.hp > self.maxhp:
self.hp = self.maxhp
print(self.name,"治疗到",self.hp)
class Player(Hero):
def __init__(self,h,a,n):
super().__init__()
self.skin = "white+balck"
self.hp = h
self.att = a
self.name = n
self.maxhp = self.hp
print("恭喜你获得英雄:" + self.name + "他的血量是:" )
p1 = Player(500,90,"张飞")
p2 = Player(300,60,"岩石")
pet = Husky()
print(pet.skin)
p1.gongji(p2)
p2.cure()
\ 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