python2

class People:
    def __init__(self, name='lll', gender='女', age=18):
        self.name = name
        self.gender = gender
        self.age = age

    def display(self):
        print("姓名:" + self.name + "\n性别:" + self.gender + "\n年龄:" + str(self.age))

class Student(People):
    def __init__(self, student_id="20210001", into_time="2021-09-01", into_score="100.0"):
        People.__init__(self, name='lll', gender='女', age=18)
        self.student_id = student_id
        self.into_time = into_time
        self.into_score = into_score

    def display(self):
        print("姓名:" + self.name + "\n性别:" + self.gender + "\n年龄:" + str(self.age) + "\n学号:" + self.student_id + "\n入学时间:" + self.into_time + "\n入学成绩:" + str(self.into_score))

class Teacher(People):
    def __init__(self, post="院长", department="软件工程学院", job_time="2000-1-01"):
        People.__init__(self, name='wsx', gender='男', age=40)
        self.post = post
        self.department = department
        self.job_time = job_time

    def display(self):
        print("姓名:" + self.name + "\n性别:" + self.gender + "\n年龄:" + str(self.age) + "\n职务:" + self.post + "\n部门:" + self.department + "\n工作时间:" + self.job_time)

class Graduate(Student):
    def __init__(self, research_fields="额", teacher="wjm"):
        Student.__init__(self, student_id="2022888", into_time="2022-09-01", into_score="60.0")
        self.research_fields = research_fields
        self.teacher = teacher

    def display(self):
        print("姓名:" + self.name + "\n性别:" + self.gender + "\n年龄:" + str(self.age) + "\n学号:" + self.student_id + "\n入学时间:" + self.into_time + "\n入学成绩:" + str(self.into_score) + "\n研究方向:" + self.research_fields + "\n导师:" + self.teacher)

class GradOnWork(Teacher, Graduate):
    def __init__(self):
        Teacher.__init__(self, post="辅导员", department="软件工程学院", job_time="2000-1-01")
        Graduate.__init__(self, research_fields="人工智能", teacher="wjm")

    def display(self):
        print("姓名:" + self.name + "\n性别:" + self.gender + "\n年龄:" + str(self.age) + "\n职务:" + self.post + "\n部门:" + self.department + "\n工作时间:" + self.job_time + "\n学号:" + self.student_id + "\n入学时间:" + self.into_time + "\n入学成绩:" + str(self.into_score) + "\n研究方向:" + self.research_fields + "\n导师:" + self.teacher)

# 创建一个 GradOnWork 对象
grad_on_work = GradOnWork()
# 调用 display() 方法打印信息
grad_on_work.display()
posted @ 2024-06-04 10:02  vvvcutee  阅读(6)  评论(0编辑  收藏  举报