python 组合样例

class Bill():
    def __init__(self, description):
        self.description = description
        
class Tail():
    def __init__(self, length):
        self.length = length
        
class Duck():
    def __init__(self, bill, tail):
        self.bill = bill
        self.tail = tail
    def about(self):
        print('This duck has a',self.bill.description,'and',self.tail.length)
        
bill = Bill('wide orage bill')
tail = Tail('long tail')
duck = Duck(bill,tail)
duck.about()

This duck has a wide orage bill and long tail

posted @ 2017-09-19 15:07  bingo彬哥  阅读(120)  评论(0编辑  收藏  举报
本站总访问量