CIT255 Lab2 solution




5/5 - (3 votes)

The primary goal of this lab is the handling of strings in the context of a static non-OO program.
You will create a class called TextHandler which will manipulate text in a number of different ways.
General Specifications
In this exercise, you will ask a user for an input string of text with no (reasonable) limits. The
program will present a interface asking the user for a string of text. The user will then get asked
what operations they want to perform on that text. At the end of each operation, the user will be
asked if they want to perform another operation on the existing text or enter a new text string on
which to handle. You must also prompt the user if they want to continue to enter text or quit and
do something more interesting.
Method Specifications
Your class must have, at a minimum, the following static methods:
1. palindrome – determines if the text is a palindrome and returns a boolean value either way.
Takes a String as parameter and returns a boolean.
2. findAllPalindromes – find if there are any palindromes anywhere in the text string. Takes a
String as a parameter, Returns each palindrome, as a String, if there are any.
3. searchText – takes a (search) String as input and searches the text to find an the number of
occurrences of the search string and returns an int as an index.
4. removeText – takes a String as input and removes all occurrences of it from the current text.
5. addText – takes an int index to show where to add the text and a String to add to the existing
6. reverseText – reverses the current text.
7. reverseEachWord – reverses each word in the current text, but the words remain in the original
8. printText – prints the text after each operation.
After each operation, the output must show the result of the operation on the submitted text
CIT255 Lab2
Complete the checkoff in lab and submit the project file(s) to Blackboard by the required date and