From 6a44b074f0169a1b0f9e92347af929c5e471746e Mon Sep 17 00:00:00 2001
From: Camil Staps
Date: Sat, 18 Apr 2015 13:44:44 +0200
Subject: Reorganised projects
---
Week5 Quiz/.gitignore | 3 +
Week5 Quiz/Assignment (in Dutch).pdf | Bin 0 -> 143371 bytes
Week5 Quiz/build.xml | 73 ++
Week5 Quiz/manifest.mf | 3 +
Week5 Quiz/nbproject/build-impl.xml | 1413 ++++++++++++++++++++++++++++++
Week5 Quiz/nbproject/genfiles.properties | 8 +
Week5 Quiz/nbproject/project.properties | 75 ++
Week5 Quiz/nbproject/project.xml | 15 +
Week5 Quiz/src/week5/MCQuestion.java | 81 ++
Week5 Quiz/src/week5/OpenQuestion.java | 32 +
Week5 Quiz/src/week5/Question.java | 56 ++
Week5 Quiz/src/week5/TCQuestion.java | 40 +
Week5 Quiz/src/week5/Week5.java | 106 +++
Week5 Quiz/week5.tar.gz | Bin 0 -> 2562 bytes
14 files changed, 1905 insertions(+)
create mode 100644 Week5 Quiz/.gitignore
create mode 100644 Week5 Quiz/Assignment (in Dutch).pdf
create mode 100644 Week5 Quiz/build.xml
create mode 100644 Week5 Quiz/manifest.mf
create mode 100644 Week5 Quiz/nbproject/build-impl.xml
create mode 100644 Week5 Quiz/nbproject/genfiles.properties
create mode 100644 Week5 Quiz/nbproject/project.properties
create mode 100644 Week5 Quiz/nbproject/project.xml
create mode 100644 Week5 Quiz/src/week5/MCQuestion.java
create mode 100644 Week5 Quiz/src/week5/OpenQuestion.java
create mode 100644 Week5 Quiz/src/week5/Question.java
create mode 100644 Week5 Quiz/src/week5/TCQuestion.java
create mode 100644 Week5 Quiz/src/week5/Week5.java
create mode 100644 Week5 Quiz/week5.tar.gz
(limited to 'Week5 Quiz')
diff --git a/Week5 Quiz/.gitignore b/Week5 Quiz/.gitignore
new file mode 100644
index 0000000..4523fc2
--- /dev/null
+++ b/Week5 Quiz/.gitignore
@@ -0,0 +1,3 @@
+nbproject/private/
+build/
+dist/
diff --git a/Week5 Quiz/Assignment (in Dutch).pdf b/Week5 Quiz/Assignment (in Dutch).pdf
new file mode 100644
index 0000000..4f6bdb6
Binary files /dev/null and b/Week5 Quiz/Assignment (in Dutch).pdf differ
diff --git a/Week5 Quiz/build.xml b/Week5 Quiz/build.xml
new file mode 100644
index 0000000..9bff533
--- /dev/null
+++ b/Week5 Quiz/build.xml
@@ -0,0 +1,73 @@
+
+
+
+
+
+
+
+
+
+
+ Builds, tests, and runs the project Week5 Quiz.
+
+
+
diff --git a/Week5 Quiz/manifest.mf b/Week5 Quiz/manifest.mf
new file mode 100644
index 0000000..328e8e5
--- /dev/null
+++ b/Week5 Quiz/manifest.mf
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+X-COMMENT: Main-Class will be added automatically by build
+
diff --git a/Week5 Quiz/nbproject/build-impl.xml b/Week5 Quiz/nbproject/build-impl.xml
new file mode 100644
index 0000000..53f5488
--- /dev/null
+++ b/Week5 Quiz/nbproject/build-impl.xml
@@ -0,0 +1,1413 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set src.dir
+ Must set test.src.dir
+ Must set build.dir
+ Must set dist.dir
+ Must set build.classes.dir
+ Must set dist.javadoc.dir
+ Must set build.test.classes.dir
+ Must set build.test.results.dir
+ Must set build.classes.excludes
+ Must set dist.jar
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ No tests executed.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set JVM to use for profiling in profiler.info.jvm
+ Must set profiler agent JVM arguments in profiler.info.jvmargs.agent
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ To run this application from the command line without Ant, try:
+
+ java -jar "${dist.jar.resolved}"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must set fix.includes
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set profile.class
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+ Some tests failed; see details above.
+
+
+
+ Must select some files in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+ Must select one file in the IDE or set test.class
+
+
+
+ Must select one file in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Week5 Quiz/nbproject/genfiles.properties b/Week5 Quiz/nbproject/genfiles.properties
new file mode 100644
index 0000000..11660ae
--- /dev/null
+++ b/Week5 Quiz/nbproject/genfiles.properties
@@ -0,0 +1,8 @@
+build.xml.data.CRC32=923bb433
+build.xml.script.CRC32=a5811974
+build.xml.stylesheet.CRC32=8064a381@1.75.2.48
+# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
+# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
+nbproject/build-impl.xml.data.CRC32=923bb433
+nbproject/build-impl.xml.script.CRC32=fe4be7f8
+nbproject/build-impl.xml.stylesheet.CRC32=876e7a8f@1.75.2.48
diff --git a/Week5 Quiz/nbproject/project.properties b/Week5 Quiz/nbproject/project.properties
new file mode 100644
index 0000000..5fccc18
--- /dev/null
+++ b/Week5 Quiz/nbproject/project.properties
@@ -0,0 +1,75 @@
+annotation.processing.enabled=true
+annotation.processing.enabled.in.editor=false
+annotation.processing.processors.list=
+annotation.processing.run.all.processors=true
+annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
+application.title=Week5 Quiz
+application.vendor=camilstaps
+build.classes.dir=${build.dir}/classes
+build.classes.excludes=**/*.java,**/*.form
+# This directory is removed when the project is cleaned:
+build.dir=build
+build.generated.dir=${build.dir}/generated
+build.generated.sources.dir=${build.dir}/generated-sources
+# Only compile against the classpath explicitly listed here:
+build.sysclasspath=ignore
+build.test.classes.dir=${build.dir}/test/classes
+build.test.results.dir=${build.dir}/test/results
+# Uncomment to specify the preferred debugger connection transport:
+#debug.transport=dt_socket
+debug.classpath=\
+ ${run.classpath}
+debug.test.classpath=\
+ ${run.test.classpath}
+# Files in build.classes.dir which should be excluded from distribution jar
+dist.archive.excludes=
+# This directory is removed when the project is cleaned:
+dist.dir=dist
+dist.jar=${dist.dir}/Week5_Quiz.jar
+dist.javadoc.dir=${dist.dir}/javadoc
+endorsed.classpath=
+excludes=
+includes=**
+jar.compress=false
+javac.classpath=
+# Space-separated list of extra javac options
+javac.compilerargs=
+javac.deprecation=false
+javac.processorpath=\
+ ${javac.classpath}
+javac.source=1.7
+javac.target=1.7
+javac.test.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}
+javac.test.processorpath=\
+ ${javac.test.classpath}
+javadoc.additionalparam=
+javadoc.author=false
+javadoc.encoding=${source.encoding}
+javadoc.noindex=false
+javadoc.nonavbar=false
+javadoc.notree=false
+javadoc.private=false
+javadoc.splitindex=true
+javadoc.use=true
+javadoc.version=false
+javadoc.windowtitle=
+main.class=week5.Week5
+manifest.file=manifest.mf
+meta.inf.dir=${src.dir}/META-INF
+mkdist.disabled=false
+platform.active=default_platform
+run.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}
+# Space-separated list of JVM arguments used when running the project.
+# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
+# To set system properties for unit tests define test-sys-prop.name=value:
+run.jvmargs=
+run.test.classpath=\
+ ${javac.test.classpath}:\
+ ${build.test.classes.dir}
+source.encoding=UTF-8
+src.dir=src
+test.src.dir=test
diff --git a/Week5 Quiz/nbproject/project.xml b/Week5 Quiz/nbproject/project.xml
new file mode 100644
index 0000000..d85592c
--- /dev/null
+++ b/Week5 Quiz/nbproject/project.xml
@@ -0,0 +1,15 @@
+
+
+ org.netbeans.modules.java.j2seproject
+
+
+ Week5 Quiz
+
+
+
+
+
+
+
+
+
diff --git a/Week5 Quiz/src/week5/MCQuestion.java b/Week5 Quiz/src/week5/MCQuestion.java
new file mode 100644
index 0000000..86869c5
--- /dev/null
+++ b/Week5 Quiz/src/week5/MCQuestion.java
@@ -0,0 +1,81 @@
+package week5;
+
+import java.util.Random;
+
+/**
+ * Class for multiple choice questions
+ *
+ * Note: for 2-choice questions the TCQuestion class should be used.
+ *
+ * @author Camil Staps, s4498062
+ */
+public class MCQuestion extends Question {
+
+ protected final String[] answers;
+ protected final int correctAnswer;
+
+ /**
+ * Construct a new instance
+ *
+ * @param question the question
+ * @param answers array of the answer
+ * @param correctAnswer index for answers pointing to the correct answer
+ * @param weight weight of the question
+ */
+ public MCQuestion (String question, String[] answers, int correctAnswer, int weight) {
+ this.question = question;
+ this.answers = answers;
+ this.correctAnswer = correctAnswer;
+ setWeight(weight);
+ }
+
+ /** See the javadoc on the constructor above */
+ public MCQuestion (String question, String[] answers, int correctAnswer) {
+ this.question = question;
+ this.answers = answers;
+ this.correctAnswer = correctAnswer;
+ }
+
+ @Override
+ public boolean isCorrect(String answer) {
+ return correctAnswer == (answer.charAt(0) - 'A');
+ }
+
+ @Override
+ public String juisteAntwoord() {
+ return answers[correctAnswer];
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder(super.toString());
+ sb.append("\n");
+ int i = 0;
+ for (String a : answers) {
+ sb.append((char) ('A' + i++)).append(": ").append(a).append("\n");
+ }
+ sb.deleteCharAt(sb.length() - 1);
+ return sb.toString();
+ }
+
+ /**
+ * For this type of questions, duplicating randomizes the order of the answers.
+ *
+ * @return A new instance of the MCQuestion class with the same parameters, just another order of the answers.
+ */
+ @Override
+ public Question duplicate() {
+ Random r = new Random();
+ int shift = r.nextInt(answers.length - 1) + 1;
+
+ String[] new_answers = new String[answers.length];
+ for (String a : answers) {
+ new_answers[shift++ % answers.length] = a;
+ }
+
+ int new_correctAnswer = (correctAnswer + shift) % answers.length;
+
+ return new MCQuestion(question, new_answers, new_correctAnswer, weight);
+ }
+
+}
diff --git a/Week5 Quiz/src/week5/OpenQuestion.java b/Week5 Quiz/src/week5/OpenQuestion.java
new file mode 100644
index 0000000..4f154ea
--- /dev/null
+++ b/Week5 Quiz/src/week5/OpenQuestion.java
@@ -0,0 +1,32 @@
+package week5;
+
+/**
+ * Class for open questions
+ *
+ * @author Camil Staps, s4498062
+ */
+public class OpenQuestion extends Question {
+
+ private final String answer;
+
+ public OpenQuestion(String question, String answer, int weight) {
+ this.question = question;
+ this.answer = answer;
+ setWeight(weight);
+ }
+
+ public OpenQuestion(String question, String answer) {
+ this.question = question;
+ this.answer = answer;
+ }
+
+ @Override
+ public boolean isCorrect(String answer) {
+ return answer.equalsIgnoreCase(this.answer);
+ }
+
+ @Override
+ public String juisteAntwoord() {
+ return answer;
+ }
+}
diff --git a/Week5 Quiz/src/week5/Question.java b/Week5 Quiz/src/week5/Question.java
new file mode 100644
index 0000000..3b05414
--- /dev/null
+++ b/Week5 Quiz/src/week5/Question.java
@@ -0,0 +1,56 @@
+package week5;
+
+/**
+ * Abstract class for quiz questions
+ *
+ * @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;
+ }
+}
diff --git a/Week5 Quiz/src/week5/TCQuestion.java b/Week5 Quiz/src/week5/TCQuestion.java
new file mode 100644
index 0000000..f89240c
--- /dev/null
+++ b/Week5 Quiz/src/week5/TCQuestion.java
@@ -0,0 +1,40 @@
+package week5;
+
+/**
+ * Class for 2-choice questions
+ *
+ * Note: for 3+-choice questions one can use MCQuestion.
+ *
+ * @author Camil Staps, s4498062
+ */
+public class TCQuestion extends MCQuestion {
+
+ /**
+ * Construct a new TCQuestion instance
+ *
+ * @param question the question
+ * @param answer1 the first answer
+ * @param answer2 the second answer
+ * @param correctAnswer 0 if answer1 is correct, 1 if answer2 is correct
+ * @param weight the weight for this question
+ */
+ public TCQuestion (String question, String answer1, String answer2, int correctAnswer, int weight) {
+ super(question, new String[] {answer1, answer2}, correctAnswer, weight);
+ }
+
+ /** See the javadoc on the constructor above */
+ public TCQuestion (String question, String answer1, String answer2, int correctAnswer) {
+ super(question, new String[] {answer1, answer2}, correctAnswer);
+ }
+
+ /**
+ * For TCQuestions we don't need to randomize the answers.
+ *
+ * @return the new question
+ */
+ @Override
+ public Question duplicate() {
+ return this;
+ }
+
+}
diff --git a/Week5 Quiz/src/week5/Week5.java b/Week5 Quiz/src/week5/Week5.java
new file mode 100644
index 0000000..24f91b2
--- /dev/null
+++ b/Week5 Quiz/src/week5/Week5.java
@@ -0,0 +1,106 @@
+package week5;
+
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Scanner;
+
+/**
+ * Uitwerking voor week 5
+ *
+ * @author Camil Staps, s4498062
+ */
+public class Week5 {
+
+ private final List questions = new LinkedList();
+ private final List questions_2 = new LinkedList();
+
+ private int score_round1 = 0;
+ private int score_round2 = 0;
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String[] args) {
+ Week5 w5 = new Week5();
+ w5.play();
+ }
+
+ /**
+ * Add default questions
+ */
+ public Week5() {
+ questions.add(new OpenQuestion("Wat is de complexiteit van binair zoeken?", "O(log N)"));
+ questions.add(new OpenQuestion("Hoe lees je in Java een integer i uit een scanner s?", "i = s.nextInt();", 2));
+ questions.add(new OpenQuestion("Is er verschil tussen een interface en een abstracte klasse?", "Ja", 5));
+ questions.add(new OpenQuestion("Hoeveel constructoren je minstens maken bij een klasse in Java?", "0", 2));
+ questions.add(new OpenQuestion("Is er een maximum aantal constructoren van een klasse in Java?", "Nee"));
+
+ questions.add(new MCQuestion("Wat is de complexiteit van slim in situ sorteren?", new String [] {
+ "O(N^2)",
+ "O(N log N)",
+ "O(N)",
+ "O(log N)"}, 1, 4));
+ questions.add(new MCQuestion("Hoe print je \"Hello world\" op een regel in Java?", new String [] {
+ "System.out.print(\"Hello world\");",
+ "System.out.println(\"Hello world\");",
+ "cout << \"Hello world\";"}, 1));
+ questions.add(new MCQuestion("Hoe lees je in Java een niet leeg woord uit scanner s?", new String []{
+ "s.nextline()",
+ "s.next(\"\\S+\")",
+ "s.next(\"\\a*\")",
+ "s.next(\"\\S*\")",
+ "s.next(\"\\\\s+\")",
+ "s.next(\"\\s+\")",
+ "s.nextString(\"\\s*\")",
+ "s.next(\"\\\\S+\")",
+ "s.nextString()"}, 7, 1));
+
+ questions.add(new TCQuestion("Deze opgave is eigenlijk niet zo moeilijk.", "Juist", "Onjuist", 0, 5));
+ }
+
+ private void play() {
+ round1();
+ System.out.println();
+ round2();
+ System.out.println();
+
+ System.out.println("Score ronde 1: " + score_round1);
+ System.out.println("Score ronde 2: " + score_round2);
+ }
+
+ private void round1() {
+ Scanner sc = new Scanner(System.in);
+
+ for (Question q : questions) {
+ System.out.println(q);
+ if (q.isCorrect(sc.nextLine())) {
+ System.out.println("Goed zo!\n");
+ score_round1 += q.getWeight();
+ } else {
+ System.out.println("Helaas...\n");
+ questions_2.add(q.duplicate());
+ }
+ }
+ }
+
+ private void round2() {
+ Scanner sc = new Scanner(System.in);
+
+ if (!questions_2.isEmpty()) {
+ System.out.println("Je krijgt een herkansing voor de " + questions_2.size() + " vragen die je zojuist fout had.\n");
+
+ for (Question q : questions_2) {
+ System.out.println(q);
+ if (q.isCorrect(sc.nextLine())) {
+ System.out.println("Goed zo!\n");
+ score_round2 += q.getWeight();
+ } else {
+ System.out.println("Helaas... het juiste antwoord was: " + q.juisteAntwoord() + "\n");
+ }
+ }
+ } else {
+ System.out.println("Alle vragen goed!");
+ }
+ }
+
+}
diff --git a/Week5 Quiz/week5.tar.gz b/Week5 Quiz/week5.tar.gz
new file mode 100644
index 0000000..7e6c609
Binary files /dev/null and b/Week5 Quiz/week5.tar.gz differ
--
cgit v1.2.3