Write a class PalindromeChecker
that includes at least two methods:
setStrictMode()
that takes a boolean
value as input, which turns "strict mode" on and offcheckPhrase()
that takes a phrase as a parameter and returns true
if the phrase is a palindrome, and false
if it isn't.If "strict mode" is on, a palindrome will only be indicated if the phrase reads exactly the same, forwards and backwards, including spaces, punctuation, and case (upper and lower). If "strict mode" is off, then spaces, punctuation, and different cases are allowed, and the phrase will be identified as a palindrome because their letters all match.
You may wish to write an additional helper method cleanPhrase()
that will produce a new, "sanitized" version of a phrase that doesn't have any spaces, punctuation, or uppercase letters in it. This method can be useful when "strict mode" is off.
Write a PalindromeCheckerTester
class that will test your PalindromeChecker
.
Sample interaction with tester:
Palindrome Checker!
Do you want strict mode 1) on, or 2) off? --> 1
Phrase: Madam in Eden, I'm Adam!
Not a palindrome.
Palindrome Checker!
Do you want strict mode 1) on, or 2) off? --> 1
Phrase: racecar a racecar
Is a palindrome.
Palindrome Checker!
Do you want strict mode 1) on, or 2) off? --> 2
Phrase: "Madam in Eden, I'm Adam!"
Is a palindrome.