Succeed_School
# 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>]
Succeed_School的更多相关文章
随机推荐
- Pytest系列(22)- allure的特性,@allure.link()、@allure.issue()、@allure.testcase()的详细使用
如果你还想从头学起Pytest,可以看看这个系列的文章哦! https://www.cnblogs.com/poloyy/category/1690628.html 前言 上一篇文章介绍了两种allu ...
- DOM对象入门
1.概念 2.script最好是放在后面,等html的文档内容加载完毕,不然获取不到 3.事件基本操作 第一种绑定事件html和js耦合度高,用第二种 4.灯开关事件使用
- 将给定数据源生成静态HTML页面持久化到项目之外的硬盘
一.java代码 设置好数据源map Map<String,String> map=new HashMap<>(); map.put("knowledgeName&q ...
- BeanFactory和ApplicationContext对比
一.BeanFactory和ApplicationContext对比 其中,ApplicationContext容器即时加载,就是一加载配置文件,就会创建对象,且自动装配bean(即写道xml中bea ...
- LVS负载均衡集群--NAT模式部署
目录: 一.企业群集应用概述 二.负载均衡群集架构 三.负载均衡群集工作模式分析 四.关于LVS虚拟服务器 五.NAT模式 LVS负载均衡群集部署 一.企业群集应用概述 1.群集的含义 Cluster ...
- 一文了解Promise使用与实现
前言 Promise 作为一个前端必备技能,不管是从项目应用还是面试,都应该对其有所了解与使用. 常常遇到的面试五连问: 说说你对 Promise 理解? Promise 的出现解决了什么问题? Pr ...
- Java中使用jxl.jar将数据导出为excel文件
Java对Excel文件的读写操作可由jxl.jar或poi.jar实现,这里使用jxl.jar完成对Excel文件的导出. 一.将Excel文件导出在本地 步骤: 创建文件 -> 创建 ...
- 每日学习——C++习题
1.题目要求:求圆的面积,数据成员为半径r,定义为私有成员,要求用成员函数实现在键盘上输入圆半径,计算圆面积.输出圆面积三个功能,要求三个成员函数在类内声明,在类外定义 //定义类 class Cir ...
- Shell系列(30)- 单分支if语句判断分区使用率
需求 监控分区已用空间,超过80%,抛出警告 脚本 #!/bin/bash #给tets赋值用于接收参数,传递给if进行判断 #申明变量test并赋值,由于赋的值是系统变量的结果,所以得用$()引用 ...
- 如何实现Orchard Core CMS的全文索引
Orchard Core提供了Lucene功能,允许您在网站上进行全文搜索.大多数情况下,在运行博客或简单的代理网站时,您可能需要在页面内容中进行搜索.在Orchard Core中,您可以使用Liqu ...