class Bird(object):
have_feather = True
way_of_reproduction = 'egg'
def move(self, x, y):
position = [0, 0]
position[0] = position[0] + x
position[1] = position[1] + y
return position
summer = Bird()
print(summer.way_of_reproduction)
# 调用move方法的时候,我们只传递了dx和dy两个参数,不需要传递self参数(因为self只是为了内部使用)
print("after move: ", summer.move(4, 5))
# 继承
# 鸡
class Chicken(Bird):
way_of_move = 'walk'
possible_in_KFC = True
# 黄鹂
class Oriole(Bird):
way_of_move = 'fly'
possible_in_KFC = False
chicken = Chicken()
oriole = Oriole()
print(chicken.have_feather)
print(chicken.move(5, 8))
print(oriole.way_of_move)
print(oriole.move(7, 8))