Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can someone please help me solve this problem? It has to be written in C++, it should have a Question.h and Question.cpp, MCquestion.h and MCquestion.cpp,

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedCan someone please help me solve this problem? It has to be written in C++, it should have a Question.h and Question.cpp, MCquestion.h and MCquestion.cpp, SAquestion.h and SAquestion.cpp, and a Quiz.h and Quiz.cpp files and finally a Main.cpp code. The Main.cpp was given already.

Question class Create a class for a question. Question -text: string +setText(string): void +getText() const: string +display() const: void +Question() +Question(string) As seen in the diagram, Question has 1 private member variable: text. Also, it has one mutator: setText; and one accessor:getText. Also, the class has a display function which shows the question's text. Finally, it has 2 constructors: a no-argument constructor, and a one-argument constructor whose argument is the question's text. The one argument constructor will only initialize the text of the question. Multiple-choice question class Create a derived class for a multiple-choice question from the question base class. Use public as the access specifier for the inheritance. MCquestion +choices: string[4] -correctAnswer: int +setCorrectAnswer(int): void +getCorrectAnswer() const: int +isCorrect(int) const: bool +display() const: void +MCquestion() +MCquestion(string) As seen in the diagram, MC question has one private member variable: correctAnswer; and a public member array, choices. Choices is an array that stores the possible answer for a question's answer. This array contains 4 strings. correctAnswer stores the position in the array which contains the correct answer. Also, it has one mutators: setCorrectAnswer; and one accessor: getCorrectAnswer. In setCorrect Answer Short-Answer question class Create a derived class for a short-answer question from the question base class. Use public as the access specifier for the inheritance. SAquestion -correctAnswer: string +setCorrectAnswer(string): void +getCorrectAnswer() const: string +isCorrect(string) const: bool +SAquestion() +SAquestion(string,string) As seen in the diagram, SA question has one private member variable: correctAnswer, which stores the text of the correct answer. Quiz class Create a class for a quiz. Quiz -score: double +question 01: MCquestion +question02: SAquestion +question03: MCquestion +question04: SAquestion +getScorel) const: double +startAttempt(): void +Quiza) As seen in the diagram, Quiz has one private member variable: score, which stores the score after an attempt. Also, it contains question01, question03 which are MCquestion objects; and question 02, question04 which are SAquestion objects. Also, it has one accessor: getScore. There is no mutator function for score. In addition, this class has a function called startAttempt, which will display each of the questions and ask for user input in each question. After each user input, determine and show whether user's answer was Class files Classes must be separated in a .h file (header), and a .cpp (source code). The main program Use that class in a main program that creates one quiz object which contains 2 multiple-choice questions, and 2 short-answer questions. You can get examples of multiple choices questions from Multiple-choice trivia questions and examples of short-answer questions from General Trivia questions. Then, execute startAttempt in the quiz object. #include #include "Quiz.h" using namespace std; int main() { cout

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

How To Build A Million Dollar Database

Authors: Michelle Bergquist

1st Edition

0615246842, 978-0615246840

More Books

Students also viewed these Databases questions