# 创建学生类
import random
class Student:
def __init__(self,num,name,address,course_lst=None):
self.num=num
self.name=name
self.address=address
if course_lst:
self.cous_lst=cous_lst
else:
self.cous_lst=[]
def look(self): #查看学生所有的课程信息
print("%s学生的选课信息:"%self.name)#输出信息提示
for el in self.cous_lst:
print(el.name,end=" ")
print()
def adds(self,s):#学生添加课程
self.cous_lst.append(s)
二、创建课程类
# 创建课程类
class Course:
def __init__(self,num,name,teacher=None):
self.num = num
self.name = name
self.teacher=teacher
def look(self):#查看课程信息
return "课程编号: %s ,课程名称: %s ,课程老师: %s " %(self.num,self.name,self.teacher)
def sett(self,t):#给课程添加老师
self.teacher=t
三、创建教师类
# 创建教师类
class Teacher:
def __init__(self,num,name,phone):
self.num = num
self.name = name
self.phone=phone