# pcj
class Dog(object):
def __init__(self,name):
self.name=name
def run(self):
print("%s只会普通的玩"% self.name)
class XiaoTiaoDog(Dog):
def run(self):
print("%s飞到天上去玩"% self.name)
class Person(object):
def __init__(self,name):
self.name=name
def game_with_dog(self,dog): #传入的是普通狗还是飞天狗,这里是关键
print("%s和%s快乐的玩"%(self.name,dog.name))
#让狗玩
dog.run()
#1 创建一个狗对象
# wangcai=Dog("旺财")
wangcai=XiaoTiaoDog("飞旺财")
# 2、创建一个小明对象
xiaoming=Person("小明")
#3、让小明和狗玩的方法
xiaoming.game_with_dog(wangcai)