58-python-组合练习

# 创建一个老师
# 有生日
# 生日也可以是一个类

class Teacher:
    def __init__(self,name,age,subject,birthday):
        self.name = name
        self.age = age
        self.subject = subject
        self.birthday = birthday

    def bir(self,birthday):
        self.birthday = birthday

class Birthday:
    def __init__(self,year,month,day):
        self.year = year
        self.month = month
        self.day = day

b = Birthday(1999,11,1)
t = Teacher('q',29,'English',b)

print(t.birthday.year)
print(t.birthday.month)
print(t.birthday.day)

  

posted @ 2018-10-28 21:35  _Q  阅读(112)  评论(0)    收藏  举报