class Dog:
def __init__(self,name,height,power):
self.name =name
self.height =height
self.power = power
self.blood = 100
def speak(self):
print(f'我是{self.name},身高{self.height},我的攻击力为{self.power}')
#牧羊犬
class SheepDog(Dog):
def __init__(self,name,height,power,num_of_sheeps):
super().__init__(name,height,power)
self.num_of_sheeps = num_of_sheeps
# 警犬
class JingQian(Dog):
def __init__(self,name,height,power,ability):
super().__init__(name,height,power)
self.ability =ability
# 宠物犬
class BabyDog(Dog):
def __init__(self,name,height,power,price):
super().__init__(name,height,power)
self.price = price
sd = SheepDog('牧羊犬1',80,100,10)
print(sd.name,sd.height,sd.power,sd.blood,sd.num_of_sheeps)
sd.speak()
jq = JingQian('警犬1',120,200,5)
print(jq.name,jq.power,jq.ability,jq.blood)
jq.speak()
bd=BabyDog("宠物犬1",50,0,5000)
print(bd.name,bd.height,bd.power,bd.price,bd.blood)
bd.speak()
请到客户端“主题--自定义配置--valine”中填入ID和KEY