我有一堂课叫做 question 。我试图通过创建其对应的对象从另一个类调用此显示方法。但我得到这个错误。如果你能帮我解决这个问题,我会很高兴。
///////////////QUESTION///////////////
function Question(id, text){
this.id = id;
this.text = text;
}
function QType1(id, text, choices, answers){
//this is true or false
Question.call(this, id, text) ;
this.choices = choices;
this.answers = answers;
}
QType1.prototype = new Question();
//inherit Question
QType1.prototype.constructor = QType1;
QType1.Display = function(){
console.log("Display Question");
}
///////////////QUIZ//////////////////
function quiz(){}
quiz.prototype.SetHomeScreen = function(x,y){
var svgCanvas = CreateCanvas(x,y);
AddText(svgCanvas,100,50, quiz_input.Settings.Layout.Text);
console.log("Text Added");
start_but = AddStartButton(svgCanvas, 300, 250);
console.log("start button Added");
start_but
.on("click", function(d,i) {
startquiz();
});
var startquiz = function(){
console.log(this);
quiz.prototype.StartQuiz();
};
}
quiz.prototype.question_objs = [];
quiz.prototype.user_ans = [];
quiz.prototype.corr_ans = [];
quiz.prototype.LoadQuestions = function(){
for(var i=0, l=questions.length; i<l; i++){
this.question_objs.push(new QType1(questions[i].id, questions[i].settings.text, questions[i].settings.choices, questions[i].settings.answers));
}
console.log(this.question_objs);
}
quiz.prototype.DisplayQuestions = function(){
var i = 0;
var l = this.question_objs.length;
while(i < l){
console.log(this.question_objs[i] instanceof QType1);
this.question_objs[i].Display();
}
}
quiz.prototype.StartQuiz = function(){
quiz.prototype.LoadQuestions();
console.log("Starting Quiz");
quiz.prototype.DisplayQuestions();
}
我得到的错误消息是。 提前致谢