Pyhton基础知识(八)面向对象
面向对象的特征:封装 集成 多态(同一类型的不同实例)
——repr——
——str——
基类和派生类
class Employee:
def init(self,department,name,birthdate,salary):
self.department=department
self.name=name
self.biethdate=birthdate
self.salary=salary
def repr(self):
return’<员工:{}>’.format(self.name)
def working(self):
print(‘员工:{},在工作’.format(self.name))
class programer(Employee):
def init(self,department,name,birthdate,salary,specialty,project):
super().init(department,name,birthdate,salary)
self.specialty=specialty
self.project=project
def working(self):
print(‘程序员:{}在开发项目:{}’.format(self.name,self.project))