面向对象的程序设计---组合练习

class Birth:
    def __init__(self,year,month,day):
        self.year=year
        self.month=month
        self.day=day
class Couse:
    def __init__(self,name):
        self.name=name
class Score:
    def __init__(self,score):
        self.score=score

class people:
    def __init__(self,name,birth,couse):
        self.name=name
        self.birth=birth
        self.couse=couse
class Teacher(people):
    pass
class Student(people):
    def __init__(self,name,birth,couse,score):
        people.__init__(self,name,birth,couse)
        self.score=score
t1=Teacher("苍老师",Birth("1985","11","11"),Couse("python"))
s1=Student("加藤同学",Birth("1975","3","15"),Couse("二指禅"),Score("666"))
print(s1.name,
      "出生于:",s1.birth.year,s1.birth.month,s1.birth.day,
      "目前专业:",s1.couse.name,
      "成绩:",s1.score.score)

  

 

转载于:https://www.cnblogs.com/mrpengfei/p/6734291.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值