Created
January 7, 2019 14:58
-
-
Save sota1235/2a890719dc686d06233e083baafaaa8a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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