I am having trouble with a class project. I am responsible for writing the 2nd part. I dont understand the add function, and I think I may have messed up the displayQuestion function. Any help is appreciated.
1. (10 pts ) Implement a class called Question. The UML below is a starting point. You may add other instance variables and methods if your group wants additional features represented. Please see the schedule for the review date of this class.
-answer : string
+Question() //constructor. Set instance variables
+Question(query : string, result : string) //constructor. Set instance variables
+getQuestion() : string //returns the question
+getAnswer : string //returns the answer to this question
+answerCorrect(candidateAnswer :string) : boolean //returns true if the candidate answer matches the answer
+displayQuestion() : void //displays this question and its answer
2. (10 pts) Implement a class called Quiz that manages an array of up to 25 Question objects. It keeps track of the correct and incorrect responses. The UML below is a starting point. Your group may add to this design and incorporate additional features. Please see the schedule for the review data of this class.
const int MAX_QUESTIONS = 25; //the size of the array
-questions : Question[MAX_QUESTIONS] //an array named questions that holds Question objects
-current : int //value of the index of the current location available in the questions array
-correct : int // number of correct answers
-incorrect : int //number of incorrect answers
+Quiz( ) //constructor. Instance variables current, correct, and incorrect set to 0.
+add(newQuestion : Question) : void //add the specified question to the questions array if room available
+giveQuiz( ) : void // present each question to the user, accept an answer for each one, and keep track of the results (the number of correct and incorrect answers).
+getNumCorrect() : int //returns the number of correct answers
+getNumIncorrect() : int //returns the number of incorrect answers
3. (10 pts) Define a tester/driver class called QuizShow with a main method that creates a Quiz object. Create 5 Question objects (read in a question and answer from a file) and populate the quiz using the add method. Then give the quiz and print the final results.
4. (10 pts Extra Credit possible) Add the following enhancements:
a. In Question, add a point value to questions.
b. In Quiz, tally up a final score.
c. In QuizShow, add a function manuallyFillQuiz that populates the quiz by prompting the user for a question and answer.
d. In QuizShow, add a function fillQuizFromFile that populates the quiz with questions and answers read in from a file.
e. In QuizShow, give the user the option of using manuallyFillQuiz or fillQuizFromFile.
f. In QuizShow, show the user’s final score.
const int MAX_QUESTIONS = 25; // size of the array
using namespace std;
void add(Question newQuestion);
* Functions *
// displays the question and verifies the answer
//Sets all variables to zero
int current = 0;
int correct = 0;
int incorrect = 0;
// displays the questions and keeps track of correct/incorrect
void Quiz::giveQuiz() : Question
cout << "******* Quiz ******* ";
cout << "Question # " << current << endl;
cout << Question displayQuestion ;
cin >> answer; // Need to define answer. How?
if (Question answerCorrect == 1)
cout << "You are correct!" << endl;
cout >> "You are incorrect!" << endl;
} while (current < = 25);
// Adds the questions to the questions array
void Quiz::add(Question newQuestion)
for (int i =0; i < MAX_QUESTIONS; i++)
// returns the number of correct answers
// returns the number of incorrect answers