• day27 作业


    # 学校类
    class School:
        #校区的名字:如"老男孩上海校区"
        #校区的地址:如"上海虹桥"
        def __init__(self,s_name,s_area):
            self.school_name = s_name
            self.school_area = s_area
        #校区创建完毕后,可以为每个校区创建班级
        def built_class(self,name,campus):
            class_obj = SchoolClass(name,campus)
            return class_obj
    # 教室类
    class SchoolClass:
        #班级名字
        #班级所在校区
        def __init__(self,c_name,c_campus):
            self.class_name = c_name
            self.class_campus = c_campus
        #班级创建完毕后,可以为每个班级创建课程
        def built_course(self,name,circle,price):
            course_obj = Course(name,circle,price)
            return course_obj
    # 课程类
    class Course:
        #课程名字
        #课程周期
        #课程价格
        def __init__(self,cou_name,circle,price):
            self.course_name = cou_name
            self.circle = circle
            self.price = price
    # 学生类
    class Student:
        def __init__(self,s_school,stu_name,age,sno,gender):
            #学生的学校
            #学生的姓名
            #学生的年龄
            #学号
            #学生的性别
            self.student_school = s_school
            self.student_name = stu_name
            self.student_age = age
            self.student_sno = sno
            self.student_gender = gender
        #学生创建完毕后,学生可以选择班级
        def choose_class(self,class_name):
            self.class_name = class_name
    # 老师类
    class Teacher:
        def __init__(self,t_name,t_age,salary,level):
            #老师的名字
            #老师的年龄
            #老师的薪资
            #老师的等级
            self.teacheer_name = t_name
            self.teacheer_age = t_age
            self.teacheer_salary = salary
            self.teacheer_level = level
            #老师创建完毕后,可以为学生打分
        def student_grade(self,student_obj,grade):
            student_obj.grade = grade
    
    
    school_1 = School("老男孩上海校区","上海虹桥")
    print(school_1.school_area)
    print(school_1.school_name)
    class_1 = school_1.built_class('14期','老男孩上海校区')
    print(class_1.class_name)
    course_1 = class_1.built_course('py全栈开发','6m','2w')
    print(course_1.circle)
    student_1 = Student('老男孩上海校区','hz','18','50','male')
    print(student_1.student_name)
    student_1.choose_class('14期')
    print(student_1.class_name)
    teacher_1 = Teacher('egon','100','3w','nb')
    print(teacher_1.teacheer_age)
    teacher_1.student_grade(student_1,100)
    print(student_1.grade)
    
  • 相关阅读:
    P1541
    P1004
    P1006
    高精度
    数组
    递归
    顺序结构
    循环结构
    变量
    分支结构
  • 原文地址:https://www.cnblogs.com/hz2lxt/p/12654894.html
Copyright © 2020-2023  润新知