首页 > 代码库 > 对象-3.py
对象-3.py
#coding: utf-8
class Member(object):
member_nums = 0
def __init__(self,name,age,sex):
self.name = name
self.age = age
self.sex = sex
self.enroll()
def enroll(self):
Member.member_nums += 1
print("THE [%s] School Member [%s] is enrolled!" %(Member.member_nums,self.name))
def tell(self):
print ("hello my name is [%s]" %self.name)
class Teacher(Member):
def __init__(self,name,age,sex,couse,salary):
super(Teacher,self).__init__(name,age,sex)
self.couse = couse
def teaching(self):
print ("Teacher [%s] is teaching [%s]" %(self.name,self.couse))
class Student(Member):
def __init__(self,name,age,sex,couse,tuition):
super(Student,self).__init__(name,age,sex)
self.couse = couse
self.tuition = tuition
def pay_tuition(self):
print (" fuck ,student [%s] paying tuition [%s]" %(self.name,self.tuition))
t1 = Teacher("alex",22,‘f‘,"PY",1000)
t2 = Teacher("box",25,"f","N/A",100)
s1 = Student("Sanjiang",24,"F","java",15000)
s2 = Student("jay",24,"m","go",14000)
t1.tell()
s1.tell()
t1.teaching()
s1.pay_tuition()
对象-3.py