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

Please solve the following problem using C++ language. Please include comments s

ID: 3877000 • Letter: P

Question

Please solve the following problem using C++ language. Please include comments so that I am able to understand the code and please follow the instructions shown. Thanks in advance.

// text.h

// test1.cpp

30 pts) On the foundation of the previous Text ADT homework, add the following methods to the Text class: 1·Implement the function to rse to reverse recursively the order of letters of the given Text object. Test your implementation by activating LAB2_TEST1 (15 pts) Function prototype: Text toReverse(Text obi, int position) const 2. Implement the operators+-. Test it by activating LAB2-TEST2. (15 pts) Function prototype: Text operator += (const Text & input2); Notel: Make Source code with the test cases are provided (text,h and test2.cpp). Make sure you create corresponding methods in text.cpp as well. There were added the following two lines into the configuration file: ingrvale corespondnd n #define LAB2 TEST! #define LAB2 TEST2 0 // Programming recursion // Programming operation and recursion Plus, there are included test cases to test your implementation.

Explanation / Answer

text.cpp : ----------------->>>>>>>>>>>> here i implemented only the toReverse and += operator function see it

#include "text.h"
#include<Cstring>

Text::Text(const Text &other){
bufferSize = other.bufferSize;
count = other.count;
strcpy(buffer,other.buffer);
}

int Text::getLength() const{
return count;
}

void Text::operator =(const Text &other){
bufferSize = other.bufferSize;
count = other.count;
strcpy(buffer,other.buffer);
}

Text::Text(const char *charSeq){
count = strlen(charSeq);
bufferSize = count+1;
strcpy(buffer,charSeq);
}

bool Text::operator <(const Text &other) const{
int ch = strcmp(buffer,other.buffer);
if(ch < 0){
  return true;
}

return false;
}

Text Text::operator +=(const Text &input2){
Text temp(buffer);
temp.count = temp.count + strlen(input2.buffer);
temp.bufferSize = temp.count + 1;
strcat(temp.buffer,input2.buffer);

return temp;
}

bool Text::operator ==(const Text &other) const{
int ch = strcmp(buffer,other.buffer);
if(ch == 0){
  return true;
}

return false;
}

bool Text::operator >(const Text &other) const{
int ch = strcmp(buffer,other.buffer);
if(ch > 0){
  return true;
}

return false;
}

void Text::showStructure() const{

}
Text Text::toLower() const{

}

Text Text::toUpper()const{

}

void Text::clear(){

}

char Text::operator [](int n)const{
return buffer[n];
}

Text::~Text(){
count = 0;
bufferSize = 0;
delete buffer;
}

Text toReverse(Text obj,int position){
if(position >= obj.getLength()/2){
  return obj;
}
char *temp;
for(int i = 0;i<obj.getLength();i++){
  temp[i] = obj[i];
}
char tmp = temp[position];
temp[position] = temp[obj.getLength() - position];
temp[obj.getLength() - position] = tmp;
Text obj1(temp);
obj1 = toReverse(obj1,position+1);
return obj1;
}