# Author kevin_hou
class School(object):
def __init__(self,name,addr):
self.name = name
self.addr = addr
self.students = []
self.staffs = []
def enroll(self,stu_obj):
self.students.append(stu_obj)
print("---------Prepare for student %s enrolling--------"%stu_obj.name)
def hire(self,staff_obj):
self.staffs.append(staff_obj)
print("---------hire a new staff %s--------"%staff_obj.name) class SchoolMember(object):
def __init__(self,name,age,sex):
self.name = name
self.age = age
self.sex = sex
def tell(self):
pass class Teacher(SchoolMember):
def __init__(self,name,age,sex,salary,course):
super(Teacher, self).__init__(name,age,sex)
self.salary = salary
self.course = course
def tell(self):
print(
'''
----------------info of Teachers: %s-------------------
Name: %s
Age: %s
Sex: %s
Salary: %s
Course: %s
'''%(self.name,self.name,self.age,self.sex,self.salary,self.course))
def tech(self):
print("%s is teasching course [%s]"%(self.name,self.course)) class Student(SchoolMember):
def __init__(self,name,age,sex,stu_id,grade):
super(Student, self).__init__(name,age,sex)
self.stu_id = stu_id
self.grade = grade
def tell(self):
print(
'''
----------------info of Students: %s-------------------
Name: %s
Age: %s
Sex: %s
Stu_id: %s
Grade: %s
''' % (self.name,self.name, self.age, self.sex, self.stu_id, self.grade))
def pay_tution(self,amount):
print("%s has paid tution for $s"%(self.name,amount))
school = School("Kevin","Shanghai")
t1 = Teacher("Alex", 22, "M", 1002,"python3")
t2 = Teacher("Jane", 33,"F",800,"C language") s1 = Student("Curry", 22, "M", 1002,"python3")
s2 = Student("Rossal", 33,"M",800,"C language") t1.tell()
# ----------------info
# of
# Teachers: Alex - ------------------
# Name: Alex
# Age: 22
# Sex: M
# Salary: 1002
# Course: python3
s1.tell()
# ----------------info
# of
# Students: Curry - ------------------
# Name: Curry
# Age: 22
# Sex: M
# Stu_id: 1002
# Grade: python3
school.hire(s1) #---------hire a new staff Curry--------
school.enroll(s1) #---------Prepare for student Curry enrolling--------
school.enroll(s2) #---------Prepare for student Rossal enrolling-------- print(school.students) #[<__main__.Student object at 0x0144CC70>, <__main__.Student object at 0x0144CCB0>]
print(school.staffs) #[<__main__.Student object at 0x0144CC70>]

  

最新文章

  1. EUI Scroller实现图片轮播 组件 ItemScroller
  2. python安装tkinter
  3. IT人的自我导向型学习:学习的1个理念和2个心态
  4. myeclipse10安装egit和使用
  5. TBluetoothLE
  6. jsp 相关特性
  7. nmap 使用脚本引擎进行扫描
  8. 使用区域组织 ASP.NET MVC 应用程序
  9. ftp服务器的搭建
  10. iOS开发之判断系统版本
  11. 【转】c++ new操作符的重载
  12. 高级软件工程2017第6次作业--团队项目:Alpha阶段综合报告
  13. [Swift]LeetCode907. 子数组的最小值之和 | Sum of Subarray Minimums
  14. [Swift]LeetCode1019. 链表中的下一个更大节点 | Next Greater Node In Linked List
  15. Redis protected-mode属性解读
  16. P2347 砝码称重-DP方案数-bitset
  17. CentOS7.3上如何安装Apache/2.4.34
  18. Future模式介绍及入门使用
  19. ID3-C45-CART
  20. Spring各个jar包作用

热门文章

  1. Hopper Disassembler系列之Sublime Text 3 爆破
  2. iNeuOS工业互联平台,增加OPC UA驱动,同步和订阅方式读取数据
  3. vuex前端工程化之动态导入文件--require.context( )
  4. CLR无法从COM 上下文*****转换为COM上下文*****,这种状态已持续60秒。
  5. POJ1804——Brainman(水题)
  6. linux停止进程
  7. Jmeter系列(17)- 常用断言之JSON断言
  8. 基于Docker构建企业Jenkins CI平台
  9. ios web 媒体查询兼容
  10. CF643F-Bears and Juice【组合数学】