案例要求忘记了(大概是……):
学生(学号,姓名,专业,所选课程{<3})
老师(工号,姓名,所教课程{<3})
课程(课程号,课程名,学分,教师,已选课学生{<30})
选课系统代码如下:
//teacher
public class Teacher {
private int id;
private String teacherName;
private Course[] courses;
//构造函数
public Teacher() {
super();
courses= new Course[3];
}
public Teacher(int id,String teacherName){
this.id=id;
this.teacherName=teacherName;
courses = new Course[3];
}
//修改或是添加属性
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getTeacherName() {
return teacherName;
}
public void setTeacherName(String teacherName) {
this.teacherName = teacherName;
}
}
/**
* 课程
*/
public class Course {
private String courseName;
private int courseId;
private Teacher teacher;
private float credit;
private Student[] students;
//构造函数
public Course(int courseId,String courseName,float credit,Teacher teacher) {
super();
this.courseId=courseId;
this.courseName=courseName;
this.credit=credit;
this.setTeacher(teacher);
students = new Student[30];
}
public Course(int courseId,String courseName,float credit) {
super();
this.courseId=courseId;
this.courseName=courseName;
this.credit=credit;
students = new Student[