R
Richard Hollenbeck
I've asked about this project before, but now I'm going to try to rewrite my
quiz program using OOP. It already works great using just plain
old-fashioned arrrays, but it is a maintenence nightmare.
If you look at the following, does this look like something I could start
with?:
function Question(q,c,a,u,n) {
this.question = q;
this.choice = c; // possible choices like "A, B, C, or D"
this.answer=a; // this would be the "correct" answer.
this.useranswer=u; // this would be the radio button the user selects
this.note=n;
}
Maybe I don't need to put the user's
answer in there at all--or do I?
the "this.note" is just in case I want to
add any comments about the question
or a comment about the correct answer
after the user answers--maybe in an "alert"
or in a "document.write."
I don't know if the question will have four
possible choices or three or five. Each
question might be different. Is that a
problem?
Also, I want to be able to randomize the
order of the questions and assign question
numbers at runtime.
Any ideas? Thanks.
Rich Hollenbeck
quiz program using OOP. It already works great using just plain
old-fashioned arrrays, but it is a maintenence nightmare.
If you look at the following, does this look like something I could start
with?:
function Question(q,c,a,u,n) {
this.question = q;
this.choice = c; // possible choices like "A, B, C, or D"
this.answer=a; // this would be the "correct" answer.
this.useranswer=u; // this would be the radio button the user selects
this.note=n;
}
Maybe I don't need to put the user's
answer in there at all--or do I?
the "this.note" is just in case I want to
add any comments about the question
or a comment about the correct answer
after the user answers--maybe in an "alert"
or in a "document.write."
I don't know if the question will have four
possible choices or three or five. Each
question might be different. Is that a
problem?
Also, I want to be able to randomize the
order of the questions and assign question
numbers at runtime.
Any ideas? Thanks.
Rich Hollenbeck