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

Using C++, The goal of this lab is to learn the use of abstract classes in C++.

ID: 3736195 • Letter: U

Question

Using C++,

The goal of this lab is to learn the use of abstract classes in C++. Consider the following abstract class Filter.

This class specifies a generic string filter. Using this class, we have implemented 7 string filters:

Capitalize;

CapitalizeFirstLetter;

CapitalizeFirstLetterOfEveryWord;

Obenglobish;

ReverseString;

ToSmall; and

Randomize.

Each of these filter is implemented in a child class of the abstract Filter class. We can apply these filters to an arbitrary string as seen below.

You are asked to provide code for the 7 classes that implement these filters. The functionality of each filter is clear from its name. Randomize filter randomly move the letter locations in the provided file. Consider the following output from the program.

  1  2  3  4  5  6  7  8  9  10  11  12  13  
  class Filter  {  protected:    string _name;    public:      Filter(const string& name) : _name(name) {}    virtual ~Filter() {};      virtual string apply(const string& input) = 0;      string get_name() { return _name; }  };

Explanation / Answer

return input;

}

};

{

return input;

}

};

class CapitalizeFirstLetter{

int len = strlen(input);

for(int i=0;i<len;++i)

{

        if(i==0)

        {

            if(islower(input[i]))

            a[i]=toupper(input[i]);

        }

        else

        {

            if(input[i]!=' ')

            {

                if(isupper(input[i]))

input[i]=tolower(input[i]);

            }

            else

            {

                i++;

                if(islower(input[i]))

input[i]=toupper(input[i]);

            }

        }

}  

  return input;

}

};

class ReverseString

{

int n = input.length();

for (int i=0; i<n/2; i++)

       swap(input[i], input[n-i-1]);

return input;

}

};

return input;

}};

class Randomize{

return input;

}

};

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