class School(object):
def __init__(self, name):
self.name = name
obj1 = School('北京')
obj2 = School('上海')
obj3 = School('深圳')
class Course(object):
def __init__(self, name, cycle, price, school=None):
self.name = name
self.cycle = cycle
self.price = price
self.school = school
python1 = Course('Python全栈', 135, 1999, obj1)
python2 = Course('Python全栈', 135, 1999, obj2)
python3 = Course('Python全栈', 135, 1999, obj3)
linux1 = Course('Linux运维', 140, 2000, obj1)
linux2 = Course('Linux运维', 140, 1865, obj2)
go = Course('go语言开发', 120, 1020, obj3)
class Grade(object):
def __init__(self, name, start_time, end_time, people_num, instructions, course):
self.name = name
self.start_time = start_time
self.end_time = end_time
self.people_num = people_num
self.instructions = instructions
self.course = course
c1 = Grade('北京Linux开发11期', '2019年5月1日', '2019年12月1日', 130, '简单介绍一下', linux1)
print('%s开课时间%s,结课时间%s,开课人数%s,介绍%s,周期%s,价格%s,地址%s' % (c1.name, c1.start_time, c1.end_time,
c1.people_num, c1.instructions, c1.course.cycle, c1.course.price, c1.course.school.name))