Question: IN C++ ,PLEASE I NEED THIS FAST IN THIS CODE NEEDS TO FIXING #include using namespace std; class AdditionQ { private: string question; string answer;

IN C++ ,PLEASE I NEED THIS FAST

IN THIS CODE NEEDS TO FIXING

#include  using namespace std; class AdditionQ { private: string question; string answer; unsigned int weight; public: AdditionQ(int pts) : question(""), answer(""), weight(pts) { } virtual void generate() { int num1 = rand() % 10; int num2 = rand() % 10; answer = to_string(num1 + num2); question = to_string(num1) + "+" + to_string(num2) + "?"; } bool check(string answer) const { return this->answer == answer; } void ask() const { cout answer == answer; } void ask() const { cout  " + to_string(num2) + " "; question += "3. " + to_string(num1) + " = " + to_string(num2) + " "; question += "Enter 1, 2 or 3: "; if (num1  num2) answer = "2"; else answer = "3"; } bool check(string answer) const { return this->answer == answer; } void ask() const { cout > ans; if (q1.check(ans)) { cout > ans; if (q2.check(ans)) { cout > ans; if (q3.check(ans)) { cout > ans; if (q4.check(ans)) { cout > ans; if (q5.check(ans)) { cout > ans; if (q6.check(ans)) { cout  

IN C++ ,PLEASE I NEED THIS FAST IN THIS CODE NEEDS TO

Ex 1. Refactoring the Classes (66 points) Fix the code duplication in the three Question classes using inheritance. Your solution is expected to contain a single base class named Question that is abstract (with at least one pure virtual function). You will be graded based on the following: The choice of the data members in the base class. The choice and implementation of the constructors in the base class and derived classes. The choice and implementation of the non-pure functions in the base class. The choice of the pure virtual function(s) in the base class and its/their implementation in the derived classes. How clean your design is from an OOP perspective. Ex 2. Refactoring the Program (34 points) Fix the code duplication in main(). Your solution is expected to create an array of 6 Question objects and loop through the array to perform exactly the same thing the original code performs

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!