I have a Student, who is in many courses, which have many Modules for each course.
So far, I have got:
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"));
Student.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);
},
This works fine. However, I would like to add Modules to this. So for each course there are multiple modules.
I have tried performing a multi-dimensional array but with no success.
Can someone please advise? Is there an alternative?
MySchool.Course? Why can't you just add another array to that for modules?var sktCourse = new MySchool.Course(...); sktCourse.addModule(new MySchool.Module(...)); myStudent.addCourse(sktCourse);