javascript

/**
*/
function Lecture(name,teacher){
 this.name=name;
 this.teacher=teacher;
}
Lecture.prototype.display=function(){
 return this.name+","+this.teacher+"\n";
}
/**
 Schedule的构造函数,以Lecture对象作为参数
*/
function Schedule(lecture){
 this.lecture=lecture;
}
Schedule.prototype.display=function(){
 var str="";
 for(var i=0;i<this.lecture.length;i++){
  str+=this.lecture[i].display();
 }
 return str;
}

var mySchedule=new Schedule([
 new Lecture("chinanes","a"),
 new Lecture("english","b"),
 new Lecture("math","c")
]);
alert(mySchedule.display());

你可能感兴趣的:(JavaScript,C++,c,prototype,C#)