# -*- coding:utf-8 -*-
class People:
school = "luffycity"
def __init__(self,name,age,sex):
self.name = name
self.age = age
self.sex = sex
class Teacher(People):
def __init__(self,name,age,sex,level,salary):
super().__init__(name,age,sex)# 继承People
self.level = level
self.salary = salary
def teach(self):
print("%s is teaching"%self.name)
class Student(People):
def __init__(self,name,age,sex,hobby):
super().__init__(name,age,sex)# 继承People
self.hobby = hobby
def learn(self):
print("%s is learning"%self.name)
class Course:
def __init__(self,name,price):
self.name = name
self.price = price
def tell_info(self):
print('%s,价格%s'%(self.name,self.price))
t1 = Teacher("alex",18,"male",10,3000)
s1 = Student('张三',18,'female','games')
# t1.teach()
# s1.learn()
C1 = Course('Python',3300)
C2 = Course('Java',3300)
t1.course = C1
t1.course.tell_info()
s1 = C2
s1.tell_info()