zoukankan      html  css  js  c++  java
  • 组合

    #!/usr/bin/env python
    # -*- coding: utf-8 -*-


    class Pople:
    school = '路飞学城'

    def __init__(self,name,age,sex):
    self.name = name
    self.age = age
    self.sex = sex

    class Teacher(Pople):

    def __init__(self,name,age,sex,level,salary):
    super().__init__(name,age,sex)

    self.level = level
    self.salary = salary

    def tell_info(self):
    print('老师名字:%s ,老师年龄:%s ,老师性别:%s ,老师等级:%s , 老师薪资:%s '%(self.name,self.age,self.sex,self.level,self.salary))

    class Student(Pople):
    def __init__(self,name,age,sex,curricula_time):
    super().__init__(name,age,sex)

    self.curricula_time = curricula_time

    def tell_info(self):
    print('学生姓名:%s , 学生年龄:%s , 学生性别:%s , 学生上课时间:%s' %(self.name,self.age,self.sex,self.curricula_time))


    class Course:
    def __init__(self,course_name,course_price,course_cycle):
    self.course_name = course_name
    self.course_price = course_price
    self.course_cycle = course_cycle

    def tell_info(self):
    print('课程名称<%s> 课程价格<%s> 课程周期<%s>' %(self.course_name,self.course_price,self.course_cycle))


    teacher1 = Teacher('alex',38,'男',20,'15k')
    teacher2 = Teacher('太白金星',49,'男',10,'13k')

    python = Course('python',8800,'6个月')
    linux = Course('linux',5000,'3个月')

    student1 = Student('kingforn',30,'男','早上9点半')
    student1.course1 = python
    student1.course2 = linux


    teacher1.course =python
    teacher2.course = linux
    teacher1.tell_info()
    teacher2.tell_info()
    teacher1.course.tell_info()
    teacher2.course.tell_info()
    student1.course1.tell_info()
    student1.course2.tell_info()
    '''
    老师名字:alex ,老师年龄:38 ,老师性别:男 ,老师等级:20 , 老师薪资:15k
    老师名字:太白金星 ,老师年龄:49 ,老师性别:男 ,老师等级:10 , 老师薪资:13k
    课程名称<python> 课程价格<8800> 课程周期<6个月>
    课程名称<linux> 课程价格<5000> 课程周期<3个月>
    课程名称<python> 课程价格<8800> 课程周期<6个月>
    课程名称<linux> 课程价格<5000> 课程周期<3个月>

    '''
  • 相关阅读:
    webpack : 无法加载文件 D: odejs ode_globalwebpack.ps1,因为在此系统上禁止运行脚本。
    TypeError: __WEBPACK_IMPORTED_MODULE_0_react___default.a.createContext is not a function报错处理
    React中import的用法
    antd-react-mobile(踩坑记录)
    [转][C#]BarCodeToHTML
    [转][C#]Environment 类
    [转][easyui]右键菜单
    [转][C#]Web.config 相关配置
    [转]模拟键盘输入
    python3 的 zip
  • 原文地址:https://www.cnblogs.com/kingforn/p/11336367.html
Copyright © 2011-2022 走看看