class Foot:
pass
class Head:
pass
class Hand:
pass
class Person:
def __init__(self,name):
self.name=name
self.foot=Foot()
self.head=Head()
self.hand=Hand()
class School:
def __init__(self,name,addr):
self.name=name
self.addr=addr
def zhao_sheng(self):
print('%s正在招生'%self.name)
class Course:
def __init__(self,name,price,period,school):
self.name=name
self.price=price
self.period=period
self.school=school
s1=School('oldboy','北京')
s2=School('oldboy','南京')
s3=School('oldboy','东京')
c1=Course('python',1000,'20h',s1)
print(c1.school.name) #oldboy
class School:
def __init__(self,name,addr):
self.name=name
self.addr=addr
def zhao_sheng(self):
print('%s正在招生'%self.name)
class Course:
def __init__(self,name,price,period,school):
self.name=name
self.price=price
self.period=period
self.school=school
s1=School('oldboy','北京')
s2=School('oldboy','南京')
s3=School('oldboy','东京')
msg='''
1 老男孩 北京校区
2 老男孩 南京校区
3 老男孩 东京校区
'''
while True:
print(msg)
menu={'1':s1,'2':s2,'3':s3}
choice=input('选择学校')
school_obj=menu[choice]
name=input('课程名')
price=input('学费')
period=input('学时')
new_course=Course(name,price,period,school_obj)
print('课程%s属于学校%s'%(new_course.name,new_course.school.name))
class School:
def __init__(self,name,addr):
self.name=name
self.addr=addr
def zhao_sheng(self):
print('%s正在招生'%self.name)
class Course:
def __init__(self,name,price,period,school):
self.name=name
self.price=price
self.period=period
self.school=school
class Teacher:
def __init__(self,name,age,teach_course):
self.name=name
self.age=age
self.teach_course=teach_course
s1=School('oldboy','北京')
s2=School('oldboy','南京')
s3=School('oldboy','东京')
c1=Course('python',1000,10,s1)
c2=Course('Java',2000,20,s2)
teacher1=Teacher('alex',30,c1)
print('%s老师今年%s岁,他所教的课程是%s,课程的学费是%s,授课地点是%s'%(teacher1.name,teacher1.age,teacher1.teach_course.name,teacher1.teach_course.price,teacher1.teach_course.school.addr))