Skip to content

Instantly share code, notes, and snippets.

@sota1235
Created January 7, 2019 14:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sota1235/2a890719dc686d06233e083baafaaa8a to your computer and use it in GitHub Desktop.
Save sota1235/2a890719dc686d06233e083baafaaa8a to your computer and use it in GitHub Desktop.
class Result {
constructor(answers) {
this.answers = answers;
}
score() {
let result = 0;
this.answers.forEach((answer) => {
question = answer.question;
result += question.score(answer.text);
});
}
}
class Answer {
constructor(question, result, text) {
this.question = question;
this.result = result;
this.text = text;
}
get question() {
return this.question;
}
get result() {
return this.result;
}
get text() {
return this.text;
}
}
class Question {
constructor(answers, correctText) {
this.answers = answers;
this.correctText = correctText;
}
score(text) {
const isCorrect = text === this.correctText;
return isCorrect ? 10 : 0;
}
}
result = new Result([]);
restul.score();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment