我有一个学生,他参加了很多课程,每门课程都有很多模块。
到目前为止,我得到了:
var myStudent = new MySchool.Student("Bart", "Simpson", "0800 Reverse", "Some Street", "Springfield");
myStudent.addCourse(new MySchool.Course("S1000", "Skateboarding"));
myStudent.addCourse(new MySchool.Course("Q1111", "Driving"));
myStudent.addCourse(new MySchool.Course("D999", "Avoiding Detention"));
学生.JS
MyStudent.Student = function (firstName, lastName, tel, address1, address2) {
this._firstName = firstName;
this._lastName = lastName;
this._tel = tel;
this._address1 = address1;
this._address2 = address2;
this._courses = new Array();
};
//Add course:
addCourse: function (course) {
this._courses.push(course);
},
这工作正常。但是,我想为此添加模块。因此,每门课程都有多个模块。
我尝试过执行多维数组,但没有成功。
有人可以建议吗?有替代方案吗?