This is a C program Write the program in computer and copy a

This is a C++ program

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.

Using our discussion and example of \"Abstract classes, design a class called Test Question. 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 gradelt0, 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 gradelt method 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 runn 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. This is enough for this assignment, but we can develop this further later.

Solution

#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 in oneTrue= \" << runningscore << endl;

       }

   }

};

class oneFalse : public TestQuestions

{

int points;

public:

   oneFalse(int n)

   {

       points = n;

   }

   void gradeIt(char c)

   {

       if ( c == \'F\' )

       {

           runningscore += points;

           cout << \"runningscore in oneFalse= \" << runningscore << endl;

       }

   }

};

class oneA : public TestQuestions

{

   int points;

public:

   oneA(int n)

   {

       points = n;

   }

   void gradeIt(char c)

   {

       if ( c == \'A\' )

       {

           runningscore += points;

           cout << \"runningscore in oneA= \" << runningscore << endl;

       }

   }

};

class oneB : public TestQuestions

{

   int points;

public:

   oneB(int n)

   {

       points = n;

   }

   void gradeIt(char c)

   {

       if ( c == \'B\' )

       {

           runningscore += points;

           cout << \"runningscore in oneB= \" << runningscore << endl;

       }

   }

};

class oneC : public TestQuestions

{

   int points;

public:

   oneC(int n)

   {

       points = n;

   }

   void gradeIt(char c)

   {

       if ( c == \'C\' )

       {

           runningscore += points;

           cout << \"runningscore in oneC= \"<<runningscore << endl;

       }

   }

};

class oneD : public TestQuestions

{

   int points;

public:

   oneD(int n)

   {

       points = n;

   }

   void gradeIt(char c)

   {

       if (c == \'D\')

       {

           runningscore += points;

           cout << \"runningscore in oneD= \" << 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\');

}

This is a C++ program 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
This is a C++ program 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
This is a C++ program 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
This is a C++ program 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
This is a C++ program 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
This is a C++ program 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

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site