This week's project is a single person project. The project is to:
Madam, I'm Adam. A man, a plan, a canal, Panama!are both palindromes.
Your palindrome detector is to read an input file and create an output file that is an exact copy of the input file, except that 3 asterisks (***) are printed at the end of each line that is a palindrome. Thus, if the input file contained the two lines above, the output file should contain:
Madam, I'm Adam. *** A man, a plan, a canal, Panama! ***Your class constructor should accept and save the names of the input and output files.
To accomplish this, your class should provide a detectPalindromes() method that opens streams to the input and output files, processes the input file line-by-line, and produces the corresponding output file. (Hint: use getline() to read a line into a string, immediately write that string to the output file, then process the string character-by-character.) Don't forget to close the streams at the end of this method.
To "process" a given string str, your checker should call an isPalindrome(str) method that returns true or false based on whether or not str is a palindrome. This method should process the string character-by character, as follows:
The twist is that for each line to be processed, your method should define your stack and queue with initial capacities of 1. You are to "wrap" the push() and append() calls in try-catch blocks. If either throws an exception (because the structure is full), your exception-handler code should:
There is one special case to cover: a blank line can (trivially) be considered to be a palindrome, but we will not do so -- your class should not mark blank lines as palindromes.
You may find some of the functions in the <cctype> library to be useful for this project.
As always, if you get to the point where you cannot figure out what is wrong, use the debugger, as it will let you trace the execution of your code one step at a time!
You should use test-driven development to build your class. Write a test class and strong test-methods for the methods in your palindrome detector class. When your palindrome detector passes all of your tests, try it on this input file as a final test. Our grader will be using it to test your program.
Create a script file in which you use ls to list all your project's files, use cat to display the contents of each file, and build+run your project to demonstrate that it works correctly using this input file. Make certain that your script file is located in your project folder.
Our grader will grade your submission based on the categories given in this grade sheet, so you should make certain all of those categories are covered.