-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQuestion.cpp
More file actions
65 lines (59 loc) · 972 Bytes
/
Copy pathQuestion.cpp
File metadata and controls
65 lines (59 loc) · 972 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include "Question.h"
#include <time.h>
Question::Question(int id, string question, string right_ans, string ans2, string ans3, string ans4)
{
_id = id;
srand(time(NULL));
bool flag;
int j;
for (int i = 0; i < 4; i++){
answers[i] = "0";
}
flag = true;
while (flag){
j = rand() % 4;
if (answers[j] == "0"){
flag = false;
answers[j] = right_ans;
}
}
flag = true;
while (flag){
j = rand() % 4;
if (answers[j] == "0"){
flag = false;
answers[j] = ans2;
}
}
flag = true;
while (flag){
j = rand() % 4;
if (answers[j] == "0"){
flag = false;
answers[j] = ans3;
}
}
flag = true;
while (flag){
j = rand() % 4;
if (answers[j] == "0"){
flag = false;
answers[j] = ans4;
}
}
}
Question::~Question()
{
}
string Question::get_question(){
return question;
}
string * Question::get_answers(){
return answers;
}
int Question::get_correct_ans_index(){
return correctansindex;
}
int Question::get_id(){
return _id;
}