Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

USING C++. PLEASE SHOW OUTPUT. Question class Create a class for a question. Question -text: string tsetText(string): void +getText() const: string +display() const: void +Question()

USING C++. PLEASE SHOW OUTPUT. image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Question class Create a class for a question. Question -text: string tsetText(string): void +getText() const: string +display() const: void +Question() +Question(string) Function/constructor description: .setText, text's mutator. .getText, text's accessor. display, shows the question's text. Question, initializes text as an empty string. Question(string), initialize text with the constructor argument. Numeric-Answer question class Create a derived class for a numeric-answer question from the question base class. Use public as the access specifier for the inheritance. NAquestion -correctAnswerMin: float -correct AnswerMax: float +setCorrect Answer( float, float): void +getCorrectAnswerMin() const: float +getCorrectAnswerMax() const: float +isCorrect(float) const: bool +NAquestion +NAquestion(string, float,float) As seen in the diagram, NA question has two private member variables: correctAnswerMin, and correctAnswerMax. correctAnswerMin and correctAnswerMax define the range of values accepted as a correct answer. Thus, correctAnswerMin is less than or equal to correctAnswerMax. Also, it has one mutator: setCorrectAnswer; and two accessors: getCorrectAnswerMin, and getCorrectAnswerMax. In setCorrectAnswer function, the first argument is the value for correctAnswerMin, and the second argument is the value for correctAnswerMax. Therefore, if the first argument's value is not less than or equal to second argument's value, do not change the values of correctAnswerMin and correctAnswerMax. In addition, this class has a function called isCorrect, which given a float argument, it will return whether that float argument is between correctAnswerMin and correctAnswerMax (true or false) Finally, it has 2 constructors: a no-argument constructor, and a three-argument constructor. The three-argument constructor will initialize the text of the question, correctAnswerMin, and correctAnswerMax. Quiz class Create a class for a quiz. Quiz -score: double -questions[4): NAquestion* +getScore() const: double #sctQuestion(int, NAQuestion*): void +getQuestion(int) const: NAquestion* tresetQuestions(): void +startAttempt(): void Quiz() As seen in the diagram, Quiz has one private member variable: score, which stores the score after an attempt. Also, it contains questions, which is an array of pointers to NAquestion objects. Also, it has two accessors: getScore, and getQuestion. getQuestion's integer argument is the position of the pointer in the array. Given the position in the array, if it points to an object, returns the pointer to that object; otherwise, returns null. Also, if position is less than 0 or greater than 3, return null. There is no mutator function for score. setQuestion is the mutator for each of the pointers to the questions. The integer argument is the position where a NAquestion pointer will be stored, and the NAquestion pointer is the object reference to store. This function will do some validations: (1) If position is less than 0 or greater than 3, do nothing. (2) If the position in the array contains a null value, update that pointer with the NAquestion pointer argument; or (3) If the position in the array contains already a NAquestion (i.e. not null), delete that NAquestion from memory; then update that pointer with the NAquestion pointer argument. resetQuestions will remove from memory the existing NAquestions pointed by questions array and set all the pointers to null. 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 correct, and count the number of right answers. At the end, calculate the score of the attempt (= right answers / number of question), a value between 0.00-100.00, display and store it in score. This function will do some validations: (1) If a position in the questions array contains a null value, does not count that question in the score, and do not try to display it. (2) If a position in the array contains a NAquestion, count that question in the score, display, and ask for user input. (3) If all positions in the array contains a null value, startAttempt do nothing. Finally, it has a no-argument constructor which initialize the pointers in the question array to null. Class files Classes must be separated in a .h file (header), and a .cpp (source code). The main program In the main program create one quiz object which contains 3 numeric-answer questions i.e. one of the pointers in the array will be null. The numeri-answer questions will be created dynamically. You can get examples of numeric-answer questions from General Trivia questions. Then, execute startAttempt in the quiz object

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

More Books

Students also viewed these Databases questions

Question

1.Which are projected Teaching aids in advance learning system?

Answered: 1 week ago

Question

What are the classifications of Bank?

Answered: 1 week ago