Everfighting
9/19/2017 - 7:04 AM

duck.py composition aggregation

duck.py composition aggregation

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()