diff options
author | Camil Staps | 2015-03-05 16:48:34 +0100 |
---|---|---|
committer | Camil Staps | 2015-03-05 16:48:34 +0100 |
commit | cefdb190155230e388c2135bec59d5ab52ff5a16 (patch) | |
tree | 25eadf04e9c44f199201ce8b35f48b4096f88acd /Week5/src/week5/Question.java | |
parent | Framework week5 (diff) |
Finished week 5
Diffstat (limited to 'Week5/src/week5/Question.java')
-rw-r--r-- | Week5/src/week5/Question.java | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/Week5/src/week5/Question.java b/Week5/src/week5/Question.java new file mode 100644 index 0000000..0c58432 --- /dev/null +++ b/Week5/src/week5/Question.java @@ -0,0 +1,57 @@ +package week5; + +/** + * Abstract class for quiz questions + * + * @author Thijs Heijligenberg, s4451414 + * @author Camil Staps, s4498062 + */ +public abstract class Question { + + protected String question = ""; + protected int weight = 3; + + @Override + public String toString() { + return question + " (pt: " + weight + ")"; + } + + /** + * Checks if a given answer is correct + * + * @param answer the answer to check + * @return true iff the answer is correct + */ + public abstract boolean isCorrect(String answer); + + /** + * Returns the correct answer + * + * @return the correct answer + */ + public abstract String juisteAntwoord(); + + /** + * Set the weight of this question (succeeds only if 0 < weight < 6) + * + * @param weight the new weight + */ + protected void setWeight(int weight) { + if (weight > 0 && weight < 6) { + this.weight = weight; + } + } + + public int getWeight() { + return weight; + } + + /** + * Create a new instance with the same parameters + * + * @return the new question + */ + public Question duplicate() { + return this; + } +} |