Question: please help me provide the member function for each class in PowerString.cpp, you should only need to work on that one file, and please read

please help me provide the member function for each class in PowerString.cpp, you should only need to work on that one file, and please read the comments in the code so you know how to help me implement them in the correct ways, thank you. here are the codes.

main.cpp:

/*

*

* Purpose: To reverse each text line, say original,

* either from the specified file passing as the command line argument

* or from the user input

* and then decide if each of original,

* is a palindrome or not

******PLEASE DO NOT CHANGE THIS FILE!******

*

*/

#include

#include

#include

#include "PowerString.h"

using namespace std;

int main(int argc, char** argv)

{

// check if the number of command line arguments is correct

if (argc < 1 || argc > 2)

{

cout << "Usage: " << argv[0] << " or " << argv[0] << " " << endl;

return 1;

}

// if there is no command line argument, read the standard input from the keyboard

if (argc == 1)

{

string original;

cout << "Please input a string to watch its magic: " << endl;

getline(cin, original);

// Stop the loop when the user clicks Ctrl-d

while (!cin.eof())

{

// create s PowerString object

PowerString magic(original);

cout << "The original string you type is: ";

magic.print();

cout << "Reverse of the string (using a loop): " << magic.rev_loop() << endl;

cout << "Reverse of the string (using recursion): " << magic.rev_recursive() << endl;

cout << "Reverse of the string (using a stack): " << magic.rev_stack() << endl << endl;

// when the boolalpha format flag is set, bool values are represented as true or false, instead of integral values

// for standard streams, the boolalpha flas is not set on initialization

cout << boolalpha;

cout << "Is \" " << magic.getString() << " \" a palindrome? " <

// note that the following two answers should always be the same

cout << "Calling member function to decide, the answer is: " << magic.isPalindrome() << endl;

cout << "Using recursion to decide, the answer is: " << magic.isPalindrome_recursive() << endl;

// asking for another input string...till the user clicks Ctrl-d

cout << endl << endl;

cout << "Please input a string to watch its magic: " << endl;

getline(cin, original);

}

return 0;

}

// if there is one command line argument, read each line from the input file

else

{

string original;

ifstream inFile;

inFile.open(argv[1]);

if (!inFile.good())

{

cout <<"File open failure!" << endl;

return 1;

}

//display each text lines from the file in original order, then followed by reversed order

cout << "Display each text line from the file in original order, then followed by the reverse order: " << endl;

while (getline(inFile, original)) // it also contains eof check, avoid an extra line

{

PowerString magic(original);

magic.print();

cout << "--> " << magic.rev_loop() << endl;

}

inFile.close();

return 0;

}

}

PowerString.cpp:

/*

* File: PowerString.cpp

* Purpose: provide the definition of the PowerString class

*

*

*

*/

#include

#include

#include "PowerString.h"

// initialize str with ini_str passing as a parameter

PowerString::PowerString(string ini_str)

{

}

// return the current value of the private data member: str

string PowerString::getString() const

{

}

// set the value of str to be the passed in parameter input_str

void PowerString::setString(string input_str)

{

}

// return a reverse string

// using a loop to implement

// Note that the private data member named str, has not been changed

string PowerString::rev_loop() const

{

}

// return a reverse string

// using recursion to implement

// Note that the private data member named str, has not been changed

string PowerString::rev_recursive() const

{

}

// return a reverse string

// using a stack to implement

// Note that the private data member named str, has not been changed

string PowerString::rev_stack() const

{

}

// return true if str is a palindrome

// otherwise return false

// A palindrome is defined as a sequence of characters which reads the same backward as forward

// calling member function to implement

// Note that the private data member named str, has not been changed

bool PowerString::isPalindrome() const

{

}

// return true if str is a palindrome

// otherwise return false

// A palindrome is defined as a sequence of characters which reads the same backward as forward

// using recursion to implement

// Note that the private data member named str, has not been changed

bool PowerString::isPalindrome_recursive() const

{

}

// displays str followed by a new line marker

// to the standard output

void PowerString::print() const

{

}

PowerString.h:

/*

* File: PowerString.h

* Purpose: provide the declaration of the PowerString class

*

*

******PLEASE DO NOT CHANGE THIS FILE!******

*

*/

#ifndef POWERSTRING_H

#define POWERSTRING_H

#include

using namespace std;

class PowerString

{

public:

// constructor: initialize str with ini_str passing as a parameter

PowerString(string ini_str);

// return the current value of the private data member: str

string getString() const;

// set the value of str to be the passed in parameter input_str

void setString(string input_str);

// return a reverse string

// using a loop to implement

// Note that the private data member named str, has not been changed

string rev_loop() const;

// return a reverse string

// using recursion to implement

// Note that the private data member named str, has not been changed

string rev_recursive() const;

// return a reverse string

// using a stack to implement

// Note that the private data member named str, has not been changed

string rev_stack() const;

// return true if str is a palindrome

// otherwise return false

// A palindrome is defined as a sequence of characters which reads the same backward as forward

// calling member function to implement

// Note that the private data member named str, has not been changed

bool isPalindrome() const;

// return true if str is a palindrome

// otherwise return false

// A palindrome is defined as a sequence of characters which reads the same backward as forward

// using recursion to implement

// Note that the private data member named str, has not been changed

bool isPalindrome_recursive() const;

// displays str, followed by a new line marker,

// to the standard output

void print() const;

private:

string str;

};

#endif /* POWERSTRING_H */

input:

race car evil olive stack cats 625 1225 2025 3025 was it a car or a cat I saw never odd or even a nut for a jar of tuna

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!