Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is a C++ program i dont know how to do it Write the program in computer and

ID: 3786152 • Letter: T

Question

This is a C++ program i dont know how to do it

Write the program in computer and copy and paste it here please so i can understand it better instead of a paper please this is C++

Using our discussion and example of "Abstract" classes, design a class called TestQuestions. The class should have one private member, an integer called "points", and a static integer field called runningscore. The class needs an abstract method(function) called gradeIt()., that takes a character argument and returns void.

Now, create SIX child classes, one True,one False, one A, one B, one C and one D. The "points" value should be added to a constructor for the child classes. Each of these has to define the gradeIt() mehtod in such a way that if the character argument is T,F,A,B,C and D respectively, add the "points" field value to the runningscore static field.

Hopefully you can see what is developing here

Finally, create an array of 10 TestQuestion's and assign a random mix of the 6 subclasses. Each question can be worth 10 points, so this is the value you will assign in the constructors.

Explanation / Answer

#include<iostream>
using namespace std;

class TestQuestions
{
   int points;
public:
   static int runningscore;
   //pure virtual function
   virtual void gradeIt(char c) = 0;
  
};
//initialize static variable
int TestQuestions::runningscore = 0;

//class definition for derived classes as follows
class oneTrue : public TestQuestions
{
   int points;
public:
   oneTrue(int n)
   {
       points = n;
   }
   void gradeIt(char c)
   {
       if (c == 'T' )
       {
           runningscore += points;
           cout << "runningscore inrunningscore inrunningscore inrunningscore inrunningscore inrunningscore in << runningscore << endl;
       }
   }
};

int main()
{
   //create 10 base pointer of base class
   TestQuestions *ptr[10];
   //create 6 childs with respective 'T' 'F' 'A' 'B' 'C' 'D'
   //create child1
   ptr[0] = new oneTrue(10);
   ptr[0]->gradeIt('T');
   //create child2
   ptr[1] = new oneFalse(20);
   ptr[1]->gradeIt('F');
   //create child3
   ptr[1] = new oneA(30);
   ptr[1]->gradeIt('A');
   //create child4
   ptr[1] = new oneB(40);
   ptr[1]->gradeIt('B');
   //create child5
   ptr[1] = new oneC(50);
   ptr[1]->gradeIt('C');
   //create child6
   ptr[1] = new oneD(60);
   ptr[1]->gradeIt('D');
   //create 6 childs without 'T' 'F' 'A' 'B' 'C' 'D'
   //create child1
   ptr[0] = new oneTrue(10);
   ptr[0]->gradeIt('A');
   //create child2
   ptr[1] = new oneFalse(20);
   ptr[1]->gradeIt('C');
   //create child3
   ptr[1] = new oneA(30);
   ptr[1]->gradeIt('F');
   //create child4
   ptr[1] = new oneB(40);
   ptr[1]->gradeIt('D');
   //create child5
   ptr[1] = new oneC(50);
   ptr[1]->gradeIt('T');
   //create child6
   ptr[1] = new oneD(60);
   ptr[1]->gradeIt('F');
}

---------------------------------------------------------------------

//output

runningscore in> runningscore in> runningscore in> runningscore in> runningscore in> runningscore in>

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote