Question: A Question Bank! In this exercise, you will implement a hierarchy of three classes that represent exam questions. The classes and their relationship are depicted

A Question Bank!
In this exercise, you will implement a hierarchy of three classes that represent exam questions. The classes and their relationship are depicted in the following UML class diagram:
Question Class
Data Members
Each question stores its text and answer (as strings) and its number of points (as an unsigned integer).
Constructor
The class must have only one constructor. This constructor must receive the question text, answer and points as arguments.
Public Functions
Beside the constructor, the class must have the following functions:
// prints out to the console the question text and the number of points void ask() const
// returns the question answer
string get_answer () const
// returns the question points.
int get_points ) const
// checks if the received answer equals the question answer
bool is_correct(string answer) const
MCQ Class
Create a class named MCQ in files mcq.h and mcq.cpp. This class represents a multiple-choice question (MCQ).
The class must inherit from class Question using public inheritance.
Data Members
Beside the question text, answer and points, each MCQ stores
an array of choices (each choice is a string),
the size of the array (i.e. the number of available choices) and
the index of the correct answer
Constructors and Destructors
The class must have only two constructors. This first constructor must be a parameterized constructor that receives as arguments
the question text,
the question points,
the array of choices and its size and
the index of the correct answer.
This constructor sets the question answer based on the given array of choices and index of the correct answer.
The second constructor is a copy constructor.
Make sure that the two constructors do a deep copy of the array of choices.
Implement also a Destructor to deallocate any dynamically allocated memory.
Public functions
Override the following function:
void ask() const
This function must print the question text followed by the choices. Each choice must be preceded by its index.
Main
Implement a simple program in test.cpp to test the classes you have implemented. Your program must perform the following:
Create at least two Question object and two MCQ object.
Allow the user to answer the created questions.
Display the total points for the questions the user answered correctly.
This is a sample output:
What is the capital of Jordan? (use Title Case)[10 points]
Irbid
WRONG!
Shuffling Choices
Implement the function void shuffle(MCQ& question) that shuffles the choices in the given McQ as follows:
Repeat 100 times the following:
Pick two random indices from the question choices array.
Swap the the two array elements.
Update the correct answer index if necessary.
Make this function a friend of class MCQ and modify your main() to test this function.
Optional. This shuffing algorthm is not a good way to shuffle. If you are interested read about Knuth Shuffle, which is simple and does the job well
*you must give me 5 files for this program
 A Question Bank! In this exercise, you will implement a hierarchy

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!