Question: Reverser.h #ifndef REVERSER_H_ #define REVERSER_H_ #include WordStack.h #include class Reverser{ private: WordStack reverser_stack; std::string original_string; public: Reverser(); std::string reverse(std::string); }; #endif /* REVERSER_H_ */ Word.h

Reverser.h

#ifndef REVERSER_H_ #define REVERSER_H_ #include "WordStack.h" #include

class Reverser{ private: WordStack reverser_stack; std::string original_string;

public: Reverser(); std::string reverse(std::string); };

#endif /* REVERSER_H_ */

Word.h

#ifndef WORD_H_ #define WORD_H_ #include ;

class Word { private: std::string word;

public: Word(); std::string getWord() const; void setWord(std::string); };

#endif

WordStack.h

#ifndef WORDSTACK_H_ #define WORDSTACK_H_

#include "Word.h"

class WordStack{ private: struct StackNode { Word word; StackNode *next; };

StackNode *top;

public: void push(Word); Word pop(); bool isEmpty() const; };

#endif /* WORDSTACK_H_ */

See the provided Word Class specification . Each Word object contains a single word stored as a string. The Word class has the following methods: string getWord() This method returns the word as a string. void setWord(string) This method sets the word value. No return. Accepts a string.

Finish the Word class implementation in Word.cpp

Create a Word Stack class with pop, push, and isEmpty. This stack holds Word objects using a linked list of Nodes. The Stack class has the following methods: void push(Word) push accepts a Word object, then inserts it into the stack of Words Word Pop() pop takes no arguments and returns the Word object from the top of the stack. This method also discards the top element from the stack. Throw an exception when popping an empty stack. bool isEmpty() isEmpty returns True when the stack is empty. False when not empty.

Finish the WordStack implementation in Wordstack.cpp.

Next, write a driver program to reverse the contents of files using your WordS tack. Create a simple text file with any arbitrary text of your choice. Write a driver that opens a text file and reads its contents into a stack of words. one word at a time. Be sure to close the file. The program should then pop the Words from the stack and save them in a second text file. This file represents the output of your program. The order of the Words saved in the second file should be the reverse of their order in the first file.

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!