EchoesOfFate
A game for our COMP315 Project
 
Loading...
Searching...
No Matches
QuestionList Class Reference

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.
 
QuestiongetCurrentQuestion ()
 iterates through the QuestionList-returns the current question and moves the current variable to the next question in the list
 
int numberOfQuestions ()
 
std::vector< QuestiongetQuestions ()
 returns a vector of Questions
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ QuestionList() [1/4]

QuestionList::QuestionList ( )

◆ QuestionList() [2/4]

QuestionList::QuestionList ( const Question & q)

Constructs a QuestionList with a single Question.

◆ QuestionList() [3/4]

QuestionList::QuestionList ( std::vector< Question > & questions)

Constructs a QuestionList from a vector of Questions.

◆ QuestionList() [4/4]

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

Member Function Documentation

◆ addLast()

void QuestionList::addLast ( const Question & q)

adds a Question to the back of the QuestionList

◆ checkQuestionExist()

bool QuestionList::checkQuestionExist ( const Question & q)

checks if a question already exists in the QuestionList

◆ getCurrentQuestion()

Question & QuestionList::getCurrentQuestion ( )

iterates through the QuestionList-returns the current question and moves the current variable to the next question in the list

◆ getQuestions()

std::vector< Question > QuestionList::getQuestions ( )

returns a vector of Questions

◆ insert()

bool QuestionList::insert ( const Question & q,
int index )

adds a Question at a specific index in the QuestionList

◆ numberOfQuestions()

int QuestionList::numberOfQuestions ( )

◆ remove()

void QuestionList::remove ( int index)

Removes from a Question from an index in the QuesstionList.


The documentation for this class was generated from the following files: