选课系统项目中涉及到诸多数据与功能,要求引入面向对象的思想对其进行高度整合
class school:
def __init__(self, school_name, school_adress):
self.name = school_name
self.adrss = school_adress
def info(self):
print(f'校名{self.name},地址{self.adrss}')
school.obj = school('oldboy', '上海青浦')
school.info(school.obj)
class course:
def __init__(self, name, period, price):
self.name = name
self.period = period
self.price = price
def info(self):
print(f'课程{self.name},课程周期{self.period},课程价格{self.price}')
course_obj = course('课程A', '14天', '20块')
course_obj.info()
class classmates:
def __init__(self, name, age, id, school, gender):
self.name = name
self.age = age
self.id = id
self.school = school
self.gender = gender
def info(self):
print(f'姓名:{self.name}年龄:{self.age}学号:{self.id}学校:{self.school}性别:{self.gender}')
wangmou = classmates('王某','18','151617','上海小天才幼儿园','男')
wangmou.info()
class teacher:
def __init__(self,name,age,salary,level):
self.name = name
self.age = age
self.salary = salary
self.level = level
def info(self):
print(f'讲师姓名:{self.name} 讲师年龄:{self.age} 讲师薪资:{self.salary} 讲师等级:{self.level} ')
teacher_obj = teacher('egon','78','588888','888')
teacher_obj.info()
class grade:
def __init__(self,name,area):
self.name = name
self.area = area
def info(self):
print(f'班级姓名:{self.name} 所属校区:{self.area} ')
grad_obj = grade('向日葵班','上海校区')
grad_obj.info()