Each level should have an instance of QuestionList Used to store and access the questions of a level-questions for a specific level are sequential and always in a fixed order regardless of what Option the user picks for questions. More...
#include <QuestionList.h>
Public Member Functions | |
| QuestionList () | |
| QuestionList (const Question &q) | |
| Constructs a QuestionList with a single Question. | |
| QuestionList (std::vector< Question > &questions) | |
| Constructs a QuestionList from a vector of Questions. | |
| QuestionList (std::string QuestionTextFileName) | |
| Creates a QuestionList from a textFile of questions and options for a specific level, each level will have its own textfile of questions. | |
| bool | checkQuestionExist (const Question &q) |
| checks if a question already exists in the QuestionList | |
| void | addLast (const Question &q) |
| adds a Question to the back of the QuestionList | |
| bool | insert (const Question &q, int index) |
| adds a Question at a specific index in the QuestionList | |
| void | remove (int index) |
| Removes from a Question from an index in the QuesstionList. | |
| Question & | getCurrentQuestion () |
| iterates through the QuestionList-returns the current question and moves the current variable to the next question in the list | |
| int | numberOfQuestions () |
| std::vector< Question > | getQuestions () |
| returns a vector of Questions | |
Each level should have an instance of QuestionList Used to store and access the questions of a level-questions for a specific level are sequential and always in a fixed order regardless of what Option the user picks for questions.
| QuestionList::QuestionList | ( | ) |
| QuestionList::QuestionList | ( | const Question & | q | ) |
Constructs a QuestionList with a single Question.
| QuestionList::QuestionList | ( | std::vector< Question > & | questions | ) |
Constructs a QuestionList from a vector of Questions.
| QuestionList::QuestionList | ( | std::string | QuestionTextFileName | ) |
Creates a QuestionList from a textFile of questions and options for a specific level, each level will have its own textfile of questions.
Creates a QuestionList from a textFile.
opens file containing the questions with options refer to the level1.txt textfile in the Questions folder to understand the format of the textfile, any change to the format will require changes here
signifies the end of the question description in the textfile and start of the options for that question
signifies the end of an Option, must be included even at the end of the last option
separates attributes of an Option-currently there are 3 attributes,if number of attributes change it will require changes to this constructor
indicates when you can go onto the options
reads the file line by line
reads in the option attributes for each option, adds it to the current question and adds the question to the list of questions
for each attribute
count goes from 0 to the number of attributes
reads line character by character
if the character read is the option delimiter, adds the last attribute of the option and then we are done with that option
adds the Option instance to the current Question instance
creates new Option for next option
gets each attribute of the Option
once an an attribute is gotten, it assigns the attribute value to the Option
if all Options have been added to the current Question, the Question gets added to the list of questions
Adds the question description to the Question
| void QuestionList::addLast | ( | const Question & | q | ) |
adds a Question to the back of the QuestionList
| bool QuestionList::checkQuestionExist | ( | const Question & | q | ) |
checks if a question already exists in the QuestionList
| Question & QuestionList::getCurrentQuestion | ( | ) |
iterates through the QuestionList-returns the current question and moves the current variable to the next question in the list
| std::vector< Question > QuestionList::getQuestions | ( | ) |
returns a vector of Questions
| bool QuestionList::insert | ( | const Question & | q, |
| int | index ) |
adds a Question at a specific index in the QuestionList
| int QuestionList::numberOfQuestions | ( | ) |
| void QuestionList::remove | ( | int | index | ) |
Removes from a Question from an index in the QuesstionList.