BZ易风

导航

 
 1 class Dog(object):
 2     def __init__(self,name):
 3         self.name = name
 4 
 5     def game(self):
 6         print("%s 蹦蹦跳跳的玩耍" % self.name)
 7 
 8 class XiaoTianDog(Dog):
 9     def game(self):
10         print("%s 飞到天上玩耍" % self.name)
11 
12 class Person(object):
13     def __init__(self,name):
14         self.name = name
15 
16 
17     def game_with_dog(self,dog):
18         print("%s 和 %s 一起玩耍" % (self.name,dog.name))
19         dog.game()
20 
21 
22 xt = XiaoTianDog("飞天旺财")
23 wc = Dog("旺财")
24 xm = Person("小明")
25 xm.game_with_dog(wc)
小明 和 旺财 一起玩耍
旺财 蹦蹦跳跳的玩耍

  

posted on 2019-08-13 14:40  BZ易风  阅读(136)  评论(0编辑  收藏  举报