组合

#组合:用来做类与类之间的关联
例如以下实例:
class Play_football:
print('正在打篮球')
class Play_baskerball:
print('正在踢足球')
class Play_volleyball:
print('正在打排球')

class Person_Play:
def __init__(self,name):
self.name = name
self.Play_football = Play_football()
self.Play_baskerball = Play_baskerball()
self.Play_vollerball = Play_volleyball ()
print('这是%s的游戏'%self.name)
p1 = Person_Play('小明')
posted @ 2021-04-13 20:46  ShadowFolk  阅读(58)  评论(0编辑  收藏  举报