Commit df53ee8b by BellCodeEditor

save project

parent a7a79e98
Showing with 33 additions and 13 deletions
class Dog: class Hero:
def __init__(self): def __init__(self):
self.footNum = 4 self.lv = 0
self.eyeNum = 2 self.hp = 0
self.head = 1 self.att = 0
self.earsNum = 2 self.name = "默认英雄"
self.skin = "white" self.maxhp = self.hp
def run(self): print("创建了一个默认英雄,他的血量是",self.hp)
print("狗狗飞快的跑起来")
def gongji(self,e):
e.hp -= self.att
print(self.name + "攻击" + e.name
+ "造成" + str(self.att) + "点伤害,"
+ e.name + "剩" + str(e.hp) + "点血。")
class Husky(Dog): def cure(self):
def __init__(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__() 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() p1.gongji(p2)
print(pet.skin) 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