forked from oleoneto/TQF
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQuestions.h
executable file
·220 lines (185 loc) · 6.94 KB
/
Questions.h
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
//
// Questions.h
// The Q Factor
//
// Created by Leo N. on 11/21/16.
// Copyright © 2016 Leo Neto. All rights reserved.
//
#ifndef Questions_h
#define Questions_h
#include "Libraries.h"
class Questions{
private:
//integers and booleans
bool is_correct;
//Strings
std::string OptionA, OptionB, OptionC, OptionD;
std::string question, correctOption, playeranswer;
//*************************************************
//*************************************************
//*************************************************
//*************************************************
//*************************************************
//*************************************************
//*************************************************
//*************************************************
//*************************************************
//*************************************************
//*************************************************
//*************************************************
//*************************************************
//*************************************************
public:
Questions(){
Questions::question = "No questions here.";
Questions::OptionA = "No options to display.";
Questions::OptionB = "No options to display.";
Questions::OptionC = "No options to display.";
Questions::OptionD = "No options to display.";
Questions::correctOption = "No answer available.";
}//constructor
~Questions(){
}//destructor
// The question constructor should take in two strings and an integer.
// The strings will be the question itself and the multiple choice answer.
// The integer will be the index of the correct answer.
void setQuestions(std::string Question, std::string a, std::string b,
std::string c, std::string d, std::string CorrectAnswer){
Questions::question = Question;
Questions::OptionA = a;
Questions::OptionB = b;
Questions::OptionC = c;
Questions::OptionD = d;
Questions::correctOption = CorrectAnswer;
}//Questions
//*************************************************
//*************************************************
//*************************************************
//*************************************************
//*************************************************
//*************************************************
//*************************************************
//*************************************************
//*************************************************
//*************************************************
//*************************************************
//*************************************************
//***** Setters for Questions *****/
void setPlayerAnswer(std::string ans){
Questions::playeranswer = ans;
}
void setQuestion(std::string question){
Questions::question = question;
}
void setOptionA(std::string a){
Questions::OptionA = a;
}
void setOptionB(std::string b){
Questions::OptionB = b;
}
void setOptionC(std::string c){
Questions::OptionC = c;
}
void setOptionD(std::string d){
Questions::OptionD = d;
}
void setAnswer(std::string answer){
Questions::correctOption = answer;
}
//*************************************************
//*************************************************
//*************************************************
//*************************************************
//*************************************************
//*************************************************
//********* Getters ********/
std::string getQuestion(){
return question;
}
std::string getOptions(){
return OptionA;
return OptionB;
return OptionC;
return OptionD;
}
std::string getOptionA(){
return OptionA;
}
std::string getOptionB(){
return OptionB;
}
std::string getOptionC(){
return OptionC;
}
std::string getOptionD(){
return OptionD;
}
std::string getAnswer(){
return correctOption;
}
std::string getCorrectAnswer(){
std::string answer;
if(this->correctOption=="a"){
answer = OptionA;
}else if (this->correctOption=="b"){
answer = OptionB;
}else if (this->correctOption=="c"){
answer = OptionC;
}else if (this->correctOption=="d"){
answer = OptionD;
}
return answer;
}
std::string getCorrectOption(){
return correctOption;
}
std::string getPlayerAnswer(){
return playeranswer;
}
//*************************************************
//*************************************************
//*************************************************
//*************************************************
//*************************************************
//*************************************************
//*** Other Methods..
// This prints a question and its four options.
// To be used if index of question is not to be shown.
void PrintMe(){
std::cout<<Questions::question<<std::endl;
std::cout<<Questions::OptionA<<std::endl;
std::cout<<Questions::OptionB<<std::endl;
std::cout<<Questions::OptionC<<std::endl;
std::cout<<Questions::OptionD<<std::endl;
}//end PrintMe()
// This prints a question and its four options. QuestionIndex is
// used to print the number of a question when it is printed.
void PrintMe(int QuestionIndex){
std::cout<<QuestionIndex<<". ";
std::cout<<Questions::question<<std::endl;
std::cout<<Questions::OptionA<<std::endl;
std::cout<<Questions::OptionB<<std::endl;
std::cout<<Questions::OptionC<<std::endl;
std::cout<<Questions::OptionD<<std::endl;
QuestionIndex++;
}//end PrintMe(int)
// This method checks if what the user enters as answer
// Matches the predefined correct option.
bool isThisCorrect(std::string useranswer){
std::string correctanswer;
correctanswer = getAnswer();
if(useranswer == correctanswer){
is_correct = true;
}else{
is_correct = false;
}
return is_correct;
}//end isThisCorrect
//*************************************************
//*************************************************
//*************************************************
//*************************************************
//*************************************************
//*************************************************
};//end Questions
#endif /* Questions_h */