4180 Project Master Code

Dependencies:   mbed 4DGL-uLCD-SE

Revision:
0:65ed62dbfeee
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/questions.cpp	Tue Apr 23 18:51:38 2019 +0000
@@ -0,0 +1,103 @@
+#include "questions.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <iostream>
+#include <time.h>
+
+questions::questions() {
+    this->question = "";
+    this->correctAnswer = "";
+    this->option1 = "";
+    this->option2 = "";
+    this->option3 = "";
+    this->option4 = "";
+    this->allOptions[0] = option1;
+    this->allOptions[1] = option2;
+    this->allOptions[2] = option3;
+    this->allOptions[3] = option4;
+}
+
+questions::questions(string question, string option1, string option2,
+    string option3, string option4, string correctAnswer) {
+
+    this->question = question;
+    this->correctAnswer = correctAnswer;
+    this->option1 = option1;
+    this->option2 = option2;
+    this->option3 = option3;
+    this->option4 = option4;
+    this->allOptions[0] = option1;
+    this->allOptions[1] = option2;
+    this->allOptions[2] = option3;
+    this->allOptions[3] = option4;
+}
+
+string questions::getQuestion() {
+    return question;
+}
+
+void questions::setQuestion(string question) {
+    this->question = question;
+}
+
+string questions::getCorrectAnswer() {
+    return correctAnswer;
+}
+
+void questions::setCorrectAnswer(string correctAnswer) {
+    this->correctAnswer = correctAnswer;
+}
+
+string questions::getOption1() {
+    return option1;
+}
+
+void questions::setOption1(string option1) {
+    this->option1 = option1;
+}
+
+string questions::getOption2() {
+    return option2;
+}
+
+void questions::setOption2(string option2) {
+    this->option2 = option2;
+}
+
+string questions::getOption3() {
+    return option3;
+}
+
+void questions::setOption3(string option3) {
+    this->option3 = option3;
+}
+
+string questions::getOption4() {
+    return option4;
+}
+
+void questions::setOption4(string option4) {
+    this->option4 = option4;
+}
+
+void questions::setAllOptions() {
+    this->allOptions[0] = option1;
+    this->allOptions[1] = option2;
+    this->allOptions[2] = option3;
+    this->allOptions[3] = option4;
+}
+
+string* questions::getAllOptions() {
+    return allOptions;
+}
+
+
+void questions::shuffleOptions() {
+    for (int i = 0; i < 15; i++) {
+        int rand1 = rand() % 4;
+        int rand2 = rand() % 4;
+        string temp = allOptions[rand1];
+        allOptions[rand1] = allOptions[rand2];
+        allOptions[rand2] = temp;
+    }
+}